Token transfer
The plugin includes multiple functions to simplify the transfer of ERC20, ERC721 and ERC1155 tokens.
Currently, it only allows for sendTransaction, which implies that the transaction content is sent to a wallet in charge of sending such transaction on the chain. In time, we should also provide functions accomodating wallet unable to send. This would mean preparing the transaction, asking for a signature from the wallet and then sending it from the game instance.
Implemented transactions
ERC20
Transfer
function transfer(address recipient, uint256 amount) external returns (bool)
Despite the From address not being sent to the contract, some wallets use this field to determine which address to use as a signer. Fill it in, unless you know it is unnecessary for your wallet.
ERC721
TransferFrom
function transferFrom(address _from, address _to, uint256 _tokenId) external payable

ERC1155
SafeTransferFrom
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external
Would be nice to have at least one batch send function. It is one of the main draws of ERC1155. Currently not supported.
How to use
Transactions can be prepared in Blueprint using the provided blueprint types (FWcERC20Transfer, FWcERC721Transfer, FWcERC1155Transfer). This may be a temporary solution, given that it requires a structure for each supported transaction.
They can then be sent using the request node corresponding to the type of contract. The response received asynchronously using these nodes is the hash of the transaction as hex, empty if it did not succeed.
In order to emit a eth_sendTransaction request, only a few field are required :
- From
- To
- ContractAddress
- ChainId
- NetUrl
- Amount/TokenId
Once prepared, they can be sent using their respective node, seen previously.