Skip to main content

4.5 Transfer

Transfers support sending tokens to multiple recipients simultaneously. Below is the definition for a transfer operation:

{
"p": "n20",
"op": "transfer",
"tick": "note",
"amt": 100 或者 [100,200,300]
... ...
}
KeyRequired?Description
pYesProtocol name, n20, lowercase
opYesOperation name, transfer, lowercase
tickYesToken name, up to 16 bytes, case-insensitive
amtYesBigint or Bigint[], a large integer or array of large integers, the amount to be transferred, must be greater than or equal to 0
...NoOther variables needed during the transfer operation

The first input of the transaction is the account initiating the operation, and the recipients are included in the transaction outputs. If the account has more tokens than the amount transferred, the excess tokens will be assigned to the next transaction output's token address for change. Otherwise, it is not necessary to specify a change token address.

Example code:

{
p:"n20",
op:"transfer",
tick:"NOTE",
amt:[100,200]
}

Transfer

The first input of the transaction unlocks the sender's UTXO, which is bound with 600 tokens. The recipients are the token addresses of the first two transaction outputs, and the third address is for change.