buildEip155Transaction
Builds an EIP-155 compliant transaction for Ethereum-compatible chains. This method constructs a transaction object that includes replay protection as specified in EIP-155.
Function Signature
Parameters
chainId
: The chain identifier in CAIP-2 format (e.g., "eip155:1" for Ethereum mainnet)params
: ABuildTransactionParam
object containing:to
: Recipient's addresstoken
: Token identifier or contract addressamount
: Amount to transfer as a string
Returns
A BuildEip115TransactionResponse
containing:
transaction
: AnEip115Transaction
object with:from
: Sender's addressto
: Recipient's addressdata
: Optional transaction data for contract interactionsvalue
: Optional transaction value in wei
metadata
: ABuildTransactionMetaData
object containing:amount
: Formatted transaction amountfromAddress
: Sender's addresstoAddress
: Recipient's addresstokenAddress
: Optional token contract address for ERC20 transferstokenDecimals
: Number of decimal places for the tokentokenSymbol
: Optional token symbolrawAmount
: Raw transaction amount value
error
: Optional error message if the build process encounters issues
Example Usage
Implementation Notes
Transaction Types:
For native ETH transfers, use "ETH" as the token identifier
For ERC20 transfers, use the token's contract address as the token identifier
Amount should be provided in the token's smallest unit (wei for ETH, token-specific decimal places for ERC20)
Token Handling:
Native ETH is identified by "ETH" token value
ERC20 tokens are identified by their contract address
Amount decimal places must match the token's decimal configuration
Amount Formats:
ETH amounts should be in wei (1 ETH = 1e18 wei)
Token amounts should account for the token's decimal places
All amounts should be provided as strings to preserve precision
Error Handling:
Check response.error for build-specific issues
Validate addresses are in correct Ethereum format
Verify amount format matches token decimals
Handle network-specific errors during transaction building
Related Documentation
For more information about transaction building, see:
Last updated
Was this helpful?