Skip to main content

Import


createEvmBuilder

Factory function to create an EVM transaction builder for a specific chain.

Signature

Parameters

config
EvmBuilderConfig
required
Configuration object for the EVM builder.

Returns

EvmBuilder
EvmBuilder
An EVM transaction builder instance.

Example


EvmBuilder Methods

buildTransfer

Builds an unsigned transfer transaction for bridging tokens from an EVM chain.

Signature

Parameters

validated
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
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

The value 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

token
Address
required
The ERC20 token contract address (without chain prefix), e.g., "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".
amount
bigint
required
The amount to approve in the token’s smallest unit.

Returns

EvmUnsignedTransaction
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

token
Address
required
The ERC20 token contract address (without chain prefix).

Returns

EvmUnsignedTransaction
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

payload
TransferPayload
required
The transfer payload containing transfer details.
signature
Uint8Array
required
The MPC signature authorizing the finalization.

Returns

EvmUnsignedTransaction
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

token
Address
required
The ERC20 token contract address to log metadata for.

Returns

EvmUnsignedTransaction
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

signature
Uint8Array
required
The MPC signature authorizing the token deployment.
metadata
TokenMetadata
required
The token metadata for the bridged token.

Returns

EvmUnsignedTransaction
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

txHash
Hex
required
The transaction hash to generate a proof for, e.g., "0x...".
topic
Hex
required
The event topic to prove. Use getInitTransferTopic() for transfer proofs.
chain
EvmChainKind
required
The EVM chain where the transaction occurred. One of: ChainKind.Eth, ChainKind.Base, ChainKind.Arb, ChainKind.Pol, ChainKind.Bnb
network
Network
required
The network: "mainnet" or "testnet".
customRpcUrl
string
Optional custom RPC URL. If not provided, uses default public RPC endpoints.

Returns

EvmProof
EvmProof
The Merkle proof data for cross-chain verification.

Example


parseInitTransferEvent

Parses the InitTransfer event from transaction logs. Works with both viem and ethers receipt log formats.

Signature

Parameters

logs
readonly LogEntry[]
required
Array of log entries from a transaction receipt.

Returns

EvmInitTransferEvent
EvmInitTransferEvent
Parsed event data.

Throws

Throws an error if no InitTransfer event is found in the logs.

Example


getInitTransferTopic

Returns the topic hash for the InitTransfer event.

Signature

Returns

Hex
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 transfer
  • finTransfer - Finalize an incoming transfer
  • deployToken - Deploy a bridged token
  • logMetadata - Log token metadata
  • nearToEthToken - Look up bridged token address
  • InitTransfer - Event emitted on transfer initiation

ERC20_ABI

A minimal ERC20 ABI with approve and allowance functions.

Types

EvmUnsignedTransaction

An unsigned EVM transaction object compatible with both viem and ethers v6.
Can be passed directly to:
  • 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

Parsed InitTransfer event from bridge transactions.

LogEntry

Log entry format compatible with both viem and ethers receipts.

Complete Transfer Example