Import
createEvmBuilder
Factory function to create an EVM transaction builder for a specific chain.Signature
Parameters
Configuration object for the EVM builder.
Returns
An EVM transaction builder instance.
Example
EvmBuilder Methods
buildTransfer
Builds an unsigned transfer transaction for bridging tokens from an EVM chain.Signature
Parameters
A validated transfer object from
bridge.validateTransfer(). The source chain in the validated transfer must match the builder’s configured chain.Returns
An unsigned transaction object compatible with viem and ethers v6.
Example
Native Token Transfers
When bridging native tokens (ETH, BNB, etc.), use the zero address:Transaction Value Calculation
Thevalue field is calculated automatically based on token type:
For ERC20 tokens, you must call
buildApproval() first to approve the bridge contract to spend your tokens.buildApproval
Builds an ERC20 approval transaction for the bridge contract.Signature
Parameters
The ERC20 token contract address (without chain prefix), e.g.,
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".The amount to approve in the token’s smallest unit.
Returns
An unsigned approval transaction. The
to field is the token contract address, and value is always 0n.Example
buildMaxApproval
Builds an unlimited (max uint256) approval transaction for the bridge contract.Signature
Parameters
The ERC20 token contract address (without chain prefix).
Returns
An unsigned approval transaction for
type(uint256).max.Example
Max approvals are convenient for repeated transfers but carry higher security risk. Consider using exact amounts for better security.
buildFinalization
Builds a finalization transaction for completing incoming transfers to an EVM chain.Signature
Parameters
The transfer payload containing transfer details.
The MPC signature authorizing the finalization.
Returns
An unsigned finalization transaction. The
value is always 0n.Example
buildLogMetadata
Builds a transaction to log token metadata on-chain. This is used to register token information for bridging.Signature
Parameters
The ERC20 token contract address to log metadata for.
Returns
An unsigned transaction to call
logMetadata on the bridge contract.Example
buildDeployToken
Builds a transaction to deploy a bridged token representation on the EVM chain.Signature
Parameters
The MPC signature authorizing the token deployment.
The token metadata for the bridged token.
Returns
An unsigned transaction to deploy the bridged token contract.
Example
Proof Utilities
getEvmProof
Generates a Merkle proof for an EVM transaction, used for cross-chain verification.Signature
Parameters
The transaction hash to generate a proof for, e.g.,
"0x...".The event topic to prove. Use
getInitTransferTopic() for transfer proofs.The EVM chain where the transaction occurred. One of:
ChainKind.Eth, ChainKind.Base, ChainKind.Arb, ChainKind.Pol, ChainKind.BnbThe network:
"mainnet" or "testnet".Optional custom RPC URL. If not provided, uses default public RPC endpoints.
Returns
The Merkle proof data for cross-chain verification.
Example
parseInitTransferEvent
Parses theInitTransfer event from transaction logs. Works with both viem and ethers receipt log formats.
Signature
Parameters
Array of log entries from a transaction receipt.
Returns
Parsed event data.
Throws
Throws an error if noInitTransfer event is found in the logs.
Example
getInitTransferTopic
Returns the topic hash for theInitTransfer event.
Signature
Returns
The keccak256 hash of the
InitTransfer event signature: "0xaa7e1f77d43faa300bc5ae8f012f0b7cf80174f4c0b1cffeab250cb4966bb88c"Example
Contract ABIs
BRIDGE_TOKEN_FACTORY_ABI
The ABI for the bridge token factory contract. Includes functions for:initTransfer- Initiate a cross-chain transferfinTransfer- Finalize an incoming transferdeployToken- Deploy a bridged tokenlogMetadata- Log token metadatanearToEthToken- Look up bridged token addressInitTransfer- Event emitted on transfer initiation
ERC20_ABI
A minimal ERC20 ABI withapprove and allowance functions.
Types
EvmUnsignedTransaction
An unsigned EVM transaction object compatible with both viem and ethers v6.- viem:
walletClient.sendTransaction(tx) - ethers v6:
signer.sendTransaction(tx)
EvmBuilderConfig
Configuration for creating an EVM builder.TokenMetadata
Metadata for deploying a bridged token.TransferPayload
Payload for finalizing an incoming transfer.EvmProof
Merkle proof data for cross-chain verification.EvmInitTransferEvent
ParsedInitTransfer event from bridge transactions.