Skip to content

Send UserOperation

Once the gas fee has been correctly prepared, we can send the UserOperation to the blockchain. With the help of CyberPaymaster, you can easily set up a UserOperation without needing to know the details of the ERC-4337 implementation of UserOperation.

When sending a UserOperation, you need to provide the following parameters:

FieldTypeDescription
toaddressThe target address to interact with
valueuint256The amount of native token to send
callDatabytesThe data to send
operationuint80 represents call, 1 represents delegatecall, and it defaults to 0. In most cases, it should not be changed

Transfer native token

For example, to send 0.1 ETH from the CyberAccount to 0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D, use the following parameters:

{
  "to": "0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D",
  "value": "100000000000000000",
  "callData": "0x",
  "operation": 0
}

Transfer ERC-20 token

For example, to send 1 CYBER(ERC-20) to 0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D on Optimism. On Optimism, the CYBER token contract address is 0x14778860E937f509e651192a90589dE711Fb88a9.

The to field is 0x14778860E937f509e651192a90589dE711Fb88a9

The callData field is the transfer(address,uint256) function call data of CYBER token contract

abi.encodeWithSignature(
    "transfer(address,uint256)",
    0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D,
    1000000000000000000);

which results in

0xa9059cbb0000000000000000000000002e0446079705b6bacc4730fb3eda5da68ae5fe4d0000000000000000000000000000000000000000000000000de0b6b3a7640000

So the parameters is as follows:

{
  "to": "0x14778860E937f509e651192a90589dE711Fb88a9",
  "value": "0",
  "callData": "0xa9059cbb0000000000000000000000002e0446079705b6bacc4730fb3eda5da68ae5fe4d0000000000000000000000000000000000000000000000000de0b6b3a7640000",
  "operation": 0
}

Transfer ERC-721 token

For example, to send 1 OPPUNK(ERC-721) with the tokenId of 1 from CyberAccount(0x6651Fa0D314C5b5818d60320C6809f6D5254Fdb9) to 0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D on Optimism. On Optimism, the OPPUNK NFT contract address is 0xB8Df6Cc3050cC02F967Db1eE48330bA23276A492.

The to field is 0xB8Df6Cc3050cC02F967Db1eE48330bA23276A492

The callData field is the safeTransferFrom(address,address,uint256) function call data of LINK3 MYSTERY BOX NFT contract

abi.encodeWithSignature(
    "safeTransferFrom(address,address,uint256)",
    0x6651Fa0D314C5b5818d60320C6809f6D5254Fdb9,
    0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D,
    1);

which results in

0x42842e0e0000000000000000000000006651fa0d314c5b5818d60320c6809f6d5254fdb90000000000000000000000002e0446079705b6bacc4730fb3eda5da68ae5fe4d0000000000000000000000000000000000000000000000000000000000000001

So the parameters is as follows:

{
  "to": "0xB8Df6Cc3050cC02F967Db1eE48330bA23276A492",
  "value": "0",
  "callData": "0x42842e0e0000000000000000000000006651fa0d314c5b5818d60320c6809f6d5254fdb90000000000000000000000002e0446079705b6bacc4730fb3eda5da68ae5fe4d0000000000000000000000000000000000000000000000000000000000000001",
  "operation": 0
}

Transfer ERC-1155 token

For example, send 10 Link3 Gemstone Avatar Frame(ERC-1155) with the tokenId of 1 from CyberAccount(0x6651Fa0D314C5b5818d60320C6809f6D5254Fdb9) to 0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D on Polygon. On Polygon, the Link3 Gemstone Avatar Frame NFT contract address is 0x3fDf5cD1F2Fbd007b833ea06C5500d67b3D6cdEc.

The to field is 0x3fDf5cD1F2Fbd007b833ea06C5500d67b3D6cdEc

The callData field is the safeTransferFrom(address,address,uint256,uint256,bytes) function call data of LINK3 Mini Shards NFT contract

abi.encodeWithSignature(
    "safeTransferFrom(address,address,uint256,uint256,bytes)",
    0x6651Fa0D314C5b5818d60320C6809f6D5254Fdb9,
    0x2E0446079705B6Bacc4730fB3EDA5DA68aE5Fe4D,
    1,
    10,
    new bytes(0));

which results in

f242432a0000000000000000000000006651fa0d314c5b5818d60320c6809f6d5254fdb90000000000000000000000002e0446079705b6bacc4730fb3eda5da68ae5fe4d0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000

So the parameters is as follows:

{
  "to": "0x3fDf5cD1F2Fbd007b833ea06C5500d67b3D6cdEc",
  "value": "0",
  "callData": "f242432a0000000000000000000000006651fa0d314c5b5818d60320c6809f6d5254fdb90000000000000000000000002e0446079705b6bacc4730fb3eda5da68ae5fe4d0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
  "operation": 0
}

Arbitrary contract call

For arbitrary contract calls, set to to the target contract address, and set callData to the function call data. Set value to the native token amount to send. The msg.sender will be the CyberAccount address in the contract call procedure.