Import
createEvmBuilder
Factory function to create an EVM transaction builder for a specific chain.Signature
Parameters
EvmBuilderConfig
required
Configuration object for the EVM builder.
Returns
EvmBuilder
An EVM transaction builder instance.
Example
EvmBuilder Methods
buildTransfer
Builds an unsigned transfer transaction for bridging tokens from an EVM chain.Signature
Parameters
ValidatedTransfer
required
A validated transfer object from
bridge.validateTransfer(). The source chain in the validated transfer must match the builder’s configured chain.Returns
EvmUnsignedTransaction
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
Address
required
The ERC20 token contract address (without chain prefix), e.g.,
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".bigint
required
The amount to approve in the token’s smallest unit.
Returns
EvmUnsignedTransaction
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
Address
required
The ERC20 token contract address (without chain prefix).
Returns
EvmUnsignedTransaction
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
TransferPayload
required
The transfer payload containing transfer details.
Uint8Array
required
The MPC signature authorizing the finalization.
Returns
EvmUnsignedTransaction
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
Address
required
The ERC20 token contract address to log metadata for.
Returns
EvmUnsignedTransaction
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
Uint8Array
required
The MPC signature authorizing the token deployment.
TokenMetadata
required
The token metadata for the bridged token.
Returns
EvmUnsignedTransaction
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
Hex
required
The transaction hash to generate a proof for, e.g.,
"0x...".Hex
required
The event topic to prove. Use
getInitTransferTopic() for transfer proofs.EvmChainKind
required
The EVM chain where the transaction occurred. One of:
ChainKind.Eth, ChainKind.Base, ChainKind.Arb, ChainKind.Pol, ChainKind.BnbNetwork
required
The network:
"mainnet" or "testnet".string
Optional custom RPC URL. If not provided, uses default public RPC endpoints.
Returns
EvmProof
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
readonly LogEntry[]
required
Array of log entries from a transaction receipt.
Returns
EvmInitTransferEvent
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
Hex
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.