Import
createNearBuilder
Factory function to create a NEAR transaction builder.Signature
Parameters
Returns
A builder instance with methods for building NEAR transactions.
Example
NearBuilder Methods
buildTransfer
Build an unsigned transfer transaction to bridge tokens from NEAR.Signature
Parameters
The validated transfer from
bridge.validateTransfer().The NEAR account ID that will sign the transaction.
Returns
An unsigned transaction ready to be signed and sent.
Example
buildStorageDeposit
Build a transaction to deposit storage on the bridge contract.Signature
Parameters
The NEAR account ID that will sign and pay for storage.
The amount of NEAR (in yoctoNEAR) to deposit for storage.
Returns
An unsigned storage deposit transaction.
Example
getRequiredStorageDeposit
Get the required storage deposit for an account on the bridge contract. Makes view calls to check current balance vs required amounts.Signature
Parameters
The NEAR account ID to check storage for.
Returns
Amount of additional storage deposit needed in yoctoNEAR. Returns
0n if sufficient storage exists.Example
isTokenStorageRegistered
Check if a token has storage registered for the bridge contract. If not, the bridge needsstorage_deposit on the token before receiving transfers.
Signature
Parameters
The token contract ID to check.
Returns
true if bridge has storage, false if storage_deposit is needed.Example
buildTokenStorageDeposit
Build a storage deposit transaction on a token contract for the bridge. This is needed before the bridge can receive tokens.Signature
Parameters
The token contract ID to register storage on.
The NEAR account ID paying for storage.
Returns
An unsigned transaction for
storage_deposit on the token contract.Example
buildFinalization
Build a transaction to finalize an incoming transfer to NEAR.Signature
Parameters
Returns
An unsigned finalization transaction.
Example
buildLogMetadata
Build a transaction to log token metadata on the bridge. This is the first step in registering a new token.Signature
Parameters
The NEAR token contract ID (e.g.,
"wrap.near").The NEAR account ID that will sign the transaction.
Returns
An unsigned log metadata transaction.
Example
buildDeployToken
Build a transaction to deploy a token on a destination chain. Used for registering NEAR tokens on other chains.Signature
Parameters
The destination chain to deploy the token on.
Serialized prover arguments (use
serializeEvmProofArgs or serializeWormholeProofArgs).The NEAR account ID that will sign the transaction.
The NEAR deposit required for deployment.
Returns
An unsigned deploy token transaction.
Example
buildBindToken
Build a transaction to bind a token from a source chain. Used for registering foreign tokens on NEAR.Signature
Parameters
The source chain where the token originates.
Serialized prover arguments.
The NEAR account ID that will sign the transaction.
The NEAR deposit required for binding.
Returns
An unsigned bind token transaction.
Example
buildSignTransfer
Build a transaction to request MPC signature for a transfer. Used by relayers.Signature
Parameters
The NEAR account to receive the relayer fee.
The NEAR account ID that will sign the transaction.
Returns
An unsigned sign transfer transaction.
Example
buildFastFinTransfer
Build a transaction for fast finalization of a transfer. Used by relayers to provide immediate liquidity.Signature
Parameters
The NEAR account ID that will sign the transaction.
Returns
An unsigned fast finalization transaction.
Example
serializeEvmProofArgs
Serialize EVM proof arguments for the prover contract.Signature
Parameters
Returns
Borsh-serialized proof arguments.
Example
serializeWormholeProofArgs
Serialize Wormhole VAA proof arguments for the prover contract.Signature
Parameters
Returns
Borsh-serialized proof arguments.
Example
UTXO Methods (BTC/Zcash)
Methods for interacting with the Bitcoin and Zcash UTXO connectors on NEAR.buildUtxoDepositFinalization
Build a transaction to finalize a UTXO deposit on NEAR. Callsverify_deposit on the connector contract.
Signature
Parameters
Returns
An unsigned verify_deposit transaction.
buildUtxoWithdrawalInit
Build a transaction to initiate a UTXO withdrawal from NEAR. Callsft_transfer_call on the nBTC/nZEC token.
Signature
Parameters
Returns
An unsigned ft_transfer_call transaction.
buildUtxoWithdrawalVerify
Build a transaction to verify a UTXO withdrawal on NEAR. Callsbtc_verify_withdraw on the connector.
Signature
Parameters
Returns
An unsigned btc_verify_withdraw transaction.
getUtxoConnectorAddress
Get the UTXO connector contract address for a chain.Signature
Parameters
The UTXO chain.
Returns
The connector contract address.
getUtxoTokenAddress
Get the UTXO token contract address for a chain.Signature
Parameters
The UTXO chain.
Returns
The token contract address (nBTC or nZEC).
getUtxoConnectorConfig
Get the UTXO connector configuration from the contract.Signature
Parameters
The UTXO chain.
Returns
getUtxoAvailableOutputs
Get available UTXOs from the connector contract.Signature
Parameters
The UTXO chain.
Returns
Array of available UTXOs for withdrawal.
getUtxoTokenBalance
Get the nBTC/nZEC token balance for an account.Signature
Parameters
The UTXO chain.
NEAR account to check balance for.
Returns
Token balance in satoshis/zatoshis.
calculateUtxoWithdrawalFee
Calculate the bridge fee for a UTXO withdrawal.Signature
Parameters
The UTXO chain.
Withdrawal amount in satoshis/zatoshis.
Returns
Bridge fee amount.
Shim Functions
Functions to convert SDK transactions to library-specific formats.toNearKitTransaction
Convert aNearUnsignedTransaction to a near-kit TransactionBuilder. near-kit handles nonce, blockHash, and signing automatically.
Signature
Parameters
A configured near-kit
Near instance.The unsigned transaction from the builder.
Returns
A near-kit TransactionBuilder that can be sent with
.send() or built with .build().Example
toNearApiJsActions
ConvertNearUnsignedTransaction actions to @near-js/transactions Action array. Use this with Account.signAndSendTransaction().
Signature
Parameters
The unsigned transaction from the builder.
Returns
Array of Action objects for use with
@near-js/accounts.Example
sendWithNearApiJs
Convenience wrapper that converts and sends a transaction using@near-js/accounts.
Signature
Parameters
A
@near-js/accounts Account instance with signer configured.The unsigned transaction from the builder.
Returns
The transaction execution outcome.
Example
MPCSignature Class
Class representing an MPC signature from the NEAR bridge contract.Constructor
Properties
The R component of the signature as an affine point.
The S component of the signature.
The recovery ID (0 or 1).
Methods
toBytes
Convert the signature to bytes for use on Solana or EVM.If
true, adds 27 to recovery_id for EVM compatibility.fromRaw (static)
Create an MPCSignature from raw contract log data.Example
calculateStorageAccountId
Calculate the storage account ID for a transfer message. This replicates the on-chain calculation.Signature
Parameters
Returns
The storage account ID as a hex string.
Example
Types
NearUnsignedTransaction
The unsigned transaction format returned by the builder.NearAction
An action within a NEAR transaction.TransferId
Identifier for a cross-chain transfer.TransferFee
Fee structure for transfers.StorageDepositAction
Action for depositing storage during finalization.UtxoPostAction
Post-action to execute after UTXO deposit is finalized.UtxoBridgeFee
Bridge fee configuration.UTXO
UTXO structure for Bitcoin/Zcash operations.Enums
ProofKind
Types of proofs for finalization and token operations.Constants
GAS
Pre-defined gas amounts for NEAR transactions.DEPOSIT
Pre-defined deposit amounts.Borsh Schemas
The package exports Borsh serialization schemas for advanced use cases.@zorsh/zorsh library and can be used for custom serialization: