Skip to main content

Burn & Mint tokens SDK Methods

In this section, we will learn about all the available Burn & Mint tokens methods provided by the SDK.

Prerequisites

  1. Initialize the SDK before using wallet methods. See the Quick Start Guide for details.
  2. All methods require a wallet. Refer to createWallet for more information.
  3. All methods require a domain parameter, which is the network domain where your wallet and providers such as blobbers, sharders, miners, and validators are deployed. GoSDK will send requests to this domain.

Burn & Mint tokens Methods

The initBridge method must be called to initialize the bridge client before using the any of the burn and mint methods.

initBridge

Initializes the bridge client.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the bridge
walletActiveWalletActive wallet details
ethereumAddressstringEthereum address of the wallet owner
bridgeAddressstringAddress of the bridge contract on the Ethereum network
authorizersAddressstringAddress of the authorizers contract on the Ethereum network
tokenAddressstringAddress of the token contract on the Ethereum network
ethereumNodeURLstringURL of the Ethereum node
gasLimitnumberGas limit for the transactions
consensusThresholdnumberConsensus threshold for the transactions

Example

import { initBridge } from '@zerochain/sdk'

await initBridge({
domain: 'mainnet.zus.network',
wallet: activeWallet,
ethereumAddress: '0x1234567890123456789012345678901234567890',
bridgeAddress: '0x7700D773022b19622095118Fadf46f7B9448Be9b',
authorizersAddress: '0x481daB4407b9880DE0A68dc62E6aF611c4949E42',
tokenAddress: '0xb9EF770B6A5e12E45983C5D80545258aA38F3B78',
ethereumNodeURL: 'https://virtual.mainnet.rpc.tenderly.co/039fdd4f-053c-4a81-9c76-db6b944c7414',
gasLimit: 3000000,
consensusThreshold: 75.0
})

burnZCN

Burns ZCN tokens.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details
amountnumberAmount of ZCN tokens to burn

Return Type

Promise<string>

Example

import { burnZCN } from '@zerochain/sdk'

const transactionHash = await burnZCN({
domain: 'mainnet.zus.network',
wallet: activeWallet,
amount: 100
})

mintZCN

Mints ZCN tokens.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details
burnTxnHashstringHash of the burn transaction
timeoutnumberTimeout in seconds (deprecated)
warning

The timeout parameter is deprecated and may be removed in future versions.

Return Type

Promise<string>

Example

import { mintZCN } from '@zerochain/sdk'

const transactionHash = await mintZCN({
domain: 'mainnet.zus.network',
wallet: activeWallet,
burnTxnHash: '0x1234567890123456789012345678901234567890123456789012345678901234',
})

getMintWZCNPayload

Returns the Mint WZCN Payload for the given burn transaction hash.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details
burnTxnHashstringHash of the burn transaction

Return Type

Promise<MintPayload>

MintPayload Type

type MintPayload = {
zcn_txn_id: string
amount: number
to: string
nonce: number
signatures: {
authorizer_id: string
signature: Uint8Array
}[]
}

Example

import { getMintWZCNPayload } from '@zerochain/sdk'

const mintPayload = await getMintWZCNPayload({
domain: 'mainnet.zus.network',
wallet: activeWallet,
burnTxnHash: '0x1234567890123456789012345678901234567890123456789012345678901234'
})

getUnprocessedWZCNBurnEvents

Returns all unprocessed WZCN burn events from the Ethereum network.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the request
walletActiveWalletActive Wallet details

Return Type

Promise<BurnEvent[]>

BurnEvent Type

type BurnEvent = {
nonce: number
amount: number
hash: string
}

Example

import { getUnprocessedWZCNBurnEvents } from '@zerochain/sdk'

const burnEvents = await getUnprocessedWZCNBurnEvents({
domain: 'mainnet.zus.network',
wallet: activeWallet
})

getProcessedZCNBurnTickets

Returns all processed ZCN burn tickets burned for a certain Ethereum address.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details

Return Type

Promise<BurnTicket[]>

BurnTicket Type

type BurnTicket = {
hash: string
amount: number
nonce: number
}

Example

import { getProcessedZCNBurnTickets } from '@zerochain/sdk'

const burnTickets = await getProcessedZCNBurnTickets({
domain: 'mainnet.zus.network',
wallet: activeWallet
})

estimateMintWZCNGasAmount

Performs gas amount estimation for the given Mint WZCN transaction.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details
fromstringAddress of the sender
tostringAddress of the receiver
zcnTransactionstringHash of the ZCN transaction
amountTokennumberAmount of tokens to mint (as a string)
noncenumberNonce of the transaction
signaturesRawstring[]Encoded format (base-64) of the burn signatures received from the authorizers

Return Type

Promise<string>

Example

import { estimateMintWZCNGasAmount } from '@zerochain/sdk'

const gasAmount = await estimateMintWZCNGasAmount({
domain: 'mainnet.zus.network',
wallet: activeWallet,
from: '0x1234567890123456789012345678901234567890',
to: '0x0987654321098765432109876543210987654321',
zcnTransaction: '0x1234567890123456789012345678901234567890123456789012345678901234',
amountToken: 10000000000,
nonce: 1,
signaturesRaw: ['signature1', 'signature2', 'signature3']
})

estimateBurnWZCNGasAmount

Performs gas amount estimation for the given burn WZCN transaction.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details
fromstringAddress of the sender
tostringAddress of the receiver
amountTokensnumberAmount of tokens to burn

Return Type

Promise<string>

Example

import { estimateBurnWZCNGasAmount } from '@zerochain/sdk'

const gasAmount = await estimateBurnWZCNGasAmount({
domain: 'mainnet.zus.network',
wallet: activeWallet,
from: '0x1234567890123456789012345678901234567890',
to: '0x0987654321098765432109876543210987654321',
amountTokens: 10000000000
})

estimateGasPrice

Performs gas estimation for the given transaction using Alchemy enhanced API, returning the approximate final gas fee.

Parameters

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the transaction
walletActiveWalletActive wallet details

Return Type

Promise<string>

Example

import { estimateGasPrice } from '@zerochain/sdk'

const gasPrice = await estimateGasPrice({
domain: 'mainnet.zus.network',
wallet: activeWallet
})