Blockchain Module

The blockchain module provides functionalities to access blockchain in your application.

Supported Chains

The below available test network are Sepolia testnets.

base, ethereum, optimism, base-test, ethereum-test, optimism-test


To get a block data from a selected chain, use block:

// Get the latest block
block base,latest;
variable blockData = @@;

// Get a specific block by block number
block base,17829399;
variable blockData = @@;


To get the id of a chain, use chain:

// Get the Optimisim chain id
chain optimisim;
variable chainId = @@;


To get the nonce of a wallet address, use nonce:

// Get the nonce of 0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326 on base
nonce base,0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326;
variable walletNonce = @@;


To get the balance of a wallet address, use balance:

// Get the balance of 0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326 on base
balance base,0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326;
variable walletBalance = @@;


To convert wei to ether unit, use ether:

// Convert 1500000000000000000 wei to 1.5 eth
ether 1500000000000000000;
variable weis = @@;


To convert ether to wei unit, use wei:

// Conver 1.5 eth to 1500000000000000000 wei
wei 1.5;
variable ethers = @@;


To convert ether to gwei unit, use gwei:

// Convert 1.5 eth to gwei
gwei 1.5;
variable gweis = @@;


To get the details of a transaction, use tx:

// Get transaction details of 0xb8bd6c0f5d315d5cc4667238417d5048c87d118c5a75d74f4126b36d580b5f4d on base
tx base, 0xb8bd6c0f5d315d5cc4667238417d5048c87d118c5a75d74f4126b36d580b5f4d;
variable transactionDetails = @@;


To convert integer to hex, use hex:

// Convert 10 to hex
hex 10;
variable hexed = @@;


A serialized transaction payload can be created using calldata.

variable contractAddress = 0x8984bC1b8731C2F73227A2a0f23D1D0Ab0c5A021;
variable walletSignerAddress = 0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326;
variable tokenRecipient = 0x1f67d4047471Aa9371C8AB3757C97eC5Dc5064E7;

// Create call parameters (transfer tokens to tokenRecipient)
variable callParams = {$tokenRecipient},100;

// Create transaction payload
calldata base, {$contractAddress}, transfer, {$callParams};
variable payload = @@;


Last updated