Closed pkieltyka closed 6 months ago
https://github.com/ethereum/aleth might have some ideas for reference
UPDATED SPEC:
Unreal Engine version support? UE5.1+
For Sequence Web3 Unreal SDK v3, aka sequence-unreal -- we will be going deeper with a closer-to-the-metal implementation compared to https://github.com/0xsequence/web3-unreal-sdk
The first step is to implement the basics of what is necessary for general Ethereum operations.
Whenever we make a smart contract call on Ethereum, what we're doing is encoding the smart contract function call and arguments with the abi encoder, and then preparing a transaction object, signing it, and then sending it over the http network. This series of steps, is exactly the different parts which will come together to provide the functionality of our library.
The functionality of the Ethereum library includes:
Now, lets break down the functionality above into the following modules:
a. json rpc http client b. abi encoder / decoder c. secp256k1 key generation/import and signing
Ethereum nodes come with a HTTP server with a simple JSON-RPC API. It's really just like any other Web API you've used before, but, it uses JSON-RPC instead of REST for the request and response data structures.
You can see the official Ethereum JSON-RPC reference methods here: https://ethereum.org/en/developers/docs/apis/json-rpc/
I also recommend to use the ethkit/ethrpc
source as a reference, as this is a full JSON-RPC Provider implementation for Ethereum. You can see the provider interface defined: https://github.com/0xsequence/ethkit/blob/master/ethrpc/interface.go
Using ethkit/ethrpc
as a reference, we can implement all of the methods over time, but I suggest to focus on the following methods to start (as this is all we really need):
Another good reference is to look at ethers.js -- see:
The abi encoder / decoder is used so we can convert between C++ data types to EVM data types. When we make a smart contract call, what we're doing is encoding the contract call and its arguments in ABI encoding, signing it and then sending it to the SendRawTransaction() (aka eth_sendTransaction JSON-RPC method).
For some references see:
Finally, we will build here a very simple / small EOA (Externally Owned Account) Signer, aka, "a wallet". We will use this very minimal wallet, so that we can sign transactions which are sent to the payload. For the Sequence wallet, we'll have higher order account type, but we will use the signer here as one of our "keys" inside of the Sequence wallet. More on the Sequence wallet later, for now lets talk about the signer.
We will need the following functions:
Reference -- here are some references to creating a minimal wallet signer:
Finally, for implementing the above, there are Ethereum C++ libraries in the wild to search/reference as well.
Interacting with Sequence wallets will be via the WaaS server backend.
The work:
Once we have our libraries in order:
An example of another project which I think strikes a decent balance of simplicity: https://www.loom.com/share/ab28ba3c47924bda9a88546e554c66d8 / https://www.usemeta.fi/demos
Unreal Engine version support? UE5.1+
For Sequence Web3 Unreal SDK v3, aka sequence-unreal -- we will be going deeper with a closer-to-the-metal implementation compared to https://github.com/0xsequence/web3-unreal-sdk
(1) Ethereum library implementation
The first step is to implement the basics of what is necessary for general Ethereum operations.
Whenever we make a smart contract call on Ethereum, what we're doing is encoding the smart contract function call and arguments with the abi encoder, and then preparing a transaction object, signing it, and then sending it over the http network. This series of steps, is exactly the different parts which will come together to provide the functionality of our library.
The functionality of the Ethereum library includes:
Now, lets break down the functionality above into the following modules:
a. json rpc http client b. abi encoder / decoder c. secp256k1 key generation/import and signing
(a) json rpc http client
Ethereum nodes come with a HTTP server with a simple JSON-RPC API. It's really just like any other Web API you've used before, but, it uses JSON-RPC instead of REST for the request and response data structures.
You can see the official Ethereum JSON-RPC reference methods here: https://ethereum.org/en/developers/docs/apis/json-rpc/
I also recommend to use the
ethkit/ethrpc
source as a reference, as this is a full JSON-RPC Provider implementation for Ethereum. You can see the provider interface defined: https://github.com/0xsequence/ethkit/blob/master/ethrpc/interface.goUsing
ethkit/ethrpc
as a reference, we can implement all of the methods over time, but I suggest to focus on the following methods to start (as this is all we really need):Another good reference is to look at ethers.js -- see:
(b) abi encoder / decoder
The abi encoder / decoder is used so we can convert between C++ data types to EVM data types. When we make a smart contract call, what we're doing is encoding the contract call and its arguments in ABI encoding, signing it and then sending it to the SendRawTransaction() (aka eth_sendTransaction JSON-RPC method).
For some references see:
(c) secp256k1 signer
Finally, we will build here a very simple / small EOA (Externally Owned Account) Signer, aka, "a wallet". We will use this very minimal wallet, so that we can sign transactions which are sent to the payload. For the Sequence wallet, we'll have higher order account type, but we will use the signer here as one of our "keys" inside of the Sequence wallet. More on the Sequence wallet later, for now lets talk about the signer.
We will need the following functions:
Reference -- here are some references to creating a minimal wallet signer:
Finally, for implementing the above, there are Ethereum C++ libraries in the wild to search/reference as well.
(2) Implement C++ Sequence library
The Sequence library is really an interface / adapter on top of the https://github.com/0xsequence/wallet-contracts smart contracts. You can think of its entire purpose is to just be able to call smart contract functions and work with data structures built on the wallet-contracts in the repo above.
For the sequence-unreal library, we will implement against the v2 wallet-contracts, you can find a reference implementation of the library to interact with v2 contracts here: https://github.com/0xsequence/sequence.js/tree/v2
The work:
(3) Implement Unreal native wallet UI
Once we have our libraries in order:
An example of another project which I think strikes a decent balance of simplicity: https://www.loom.com/share/ab28ba3c47924bda9a88546e554c66d8 / https://www.usemeta.fi/demos