Binance Smart Chain

Wallet Structure

The custodial wallet of Binance Smart Chain has the following structure.

  • Main Address
  • Fee Address
  • Child Address

TIP
The fee address is used to recharge the child address with the fees (BNB) required to gather tokens.






Child Address

Generates child addresses by calling the Generate Child Address API. Generally, one child address is given to each end user. Generated child addresses can be checked from [Child Address Information] from the console or by calling the Access Child Address List API.

Response example

[
  {
    "address": "0x236c41418f0320DC7233C8c9dC99EEa5930341D9",
    "name": "test bnb address"
  }
]





Deposit

Deposit Status

When an asset from the outside arrives at the main or a child address, Octet recognizes it as a deposit. However, the deposit is not finalized even if the deposit transaction is included in the blocks. Additional blocks must be generated to finalize(FINALIZED) the transaction to ensure the integrity of the transaction. When an asset is sent to a main or a child address but has not arrived, that transaction is not recognized. Therefore, there is no FAILED status for the deposit transaction.

Status nameDescription
UNFINALIZEDDeposit transaction is included in the blocks
FINALIZEDDeposit transaction is included in the blocks and the next block is generated

The number of blocks required to finalize the deposit is different depending on the network. Both testnet and mainnet require additional 20 blocks to finalize the transaction.

TestnetMainnet
20 block (about 1 minute)20 block (about 1 minute)


Deposit Confirmation

1. Checking from the Console

You can check the deposit status from [Transaction History] on the console. UNFINALIZED deposits are displayed as ‘Processing’, and FINALIZED deposits are displayed as ‘Completed’.


2. Checking with Webhooks

When a deposit is finalized to a main or a child address, a deposit webhook will be sent. You can check the deposit status from the received webhook. For more information about how to use webhooks and their data structure, check the 'Webhook' page.






Gathering

Gathering Process and Fees

Assets stored in child addresses don’t move to the main address unless gathering is requested. Therefore, gatherings should be made regularly to avoid a deficit in the main address.

When a gathering of a specific asset is requested, all BNBs or tokens stored in every child address transfer to the main address. At this point, one transaction occurs per each child address. For example, when 10 child addresses store BNBs, 10 transactions will occur in total.


1. Gathering BNBs

A BNB gathering fee occurs for each transaction, and it is deducted from the asset to be gathered. Gathering will not be made for child addresses with assets less than the expected fees. Gathering process is as follows.

  1. Request gathering.
  2. Generate a transaction for each child addresses to be gathered.
  3. Calculates the optimal fees and propagates the transactions.
  4. Gathering is completed when transactions are confirmed in the blocks.

2. Gathering Tokens

A token-gathering fee occurs for each transaction. When there are not enough BNBs in the child address, BNBs in the fee address will be recharged to the child address. A fee (fee-recharging cost) will occur for this process as well. The child address pays the fee with the transferred BNBs and proceeds with the gathering. Gathering process is as follows.

  1. Request gathering.
  2. Recharge BNBs to pay the fee from the fee address to the child address.
  3. Generate a transaction for each child addresses to be gathered.
  4. Calculates the optimal fees and propagates the transactions.
  5. Gathering is completed when transactions are confirmed in the blocks.


Gathering Status

Gathering status can be specified into seven types, depending on the process. The asset stored in the child address is in AWAITING_GATHERING status.

When it needs a recharging of fees for the gathering, the status of the asset changes to AWAITING_FEE_INJECTION. When the fee transfer transaction is generated, the status of the asset changes to FEE_INJECTING. When it fails to recharge the fee, the status of the asset is processed to FEE_INJECTION_FAILED.

When the fee transfer is successful and generates a gathering transaction, the asset status changes to GATHERING. When the transaction is included in the blocks, the status of the asset is processed to COMPLETED and finishes the gathering.

When a gathering is tried and failed, the status of the asset remains as GATHERING_FAILED. Assets with a status of fee injection failed or gathering failed are included in the gathering target again. When a gathering is tried but failed to generate a transaction due to insufficient fees, it remains in AWAITING_GATHERING status.

Status nameDescription
AWAITING_GATHERINGAwaiting gathering
AWAITING_FEE_INJECTIONAwaiting fee injection
FEE_INJECTINGProcessing fee injection
FEE_INJECTION_FAILEDFailed fee injection
GATHERINGGenerate gathering transaction
COMPLETEDComplete gathering transaction
GATHERING_FAILEDFailed gathering transaction


Gather

Transfers the assets stored in the child address to the main address. Gatherings can be processed by one of the following two methods.

1. Gathering from the Console

You can gather from Console - Select a wallet - [Gathering History]. Click the [Gather] button, check the assets and the amount to gather, then proceed with the gathering.


2. Gathering with API

The gathering will be processed by calling the Request Gathering API.

Response example

[
  {
    "success": true,
    "uuid": "97410344-a48b-4f7e-a1ee-2feff91bebaa",
    "childAddresses": [
      "0x42d0aAE9A2305D66d20bE4361535FdB44670F933"
    ]
  },
  {
    "success": false,
    "childAddresses": [
      "0x94c1e678705cA8FB2d5929B37d01aAb14ffA9D7d"
    ],
    "errorCode": "ERR_0420002",
    "errorMessage": "The amount to be gathered is less than the minimum amount to be gathered."
  }
]


Gathering Status Confirmation

1. Checking from the Console

You can check the gathering history from Select a wallet - [Gathering History] - [Gathering History].


2. Checking with API

You can check the gathering history by calling the Access Gathering Request Information API.

Response example

[
  {
    "idx": 66,
    "status": "COMPLETED",
    "createdDate": "2021-12-29T08:09:03.777Z",
    "modifiedDate": "2021-12-29T08:20:00.000Z",
    "coin": {
      "idx": 1,
      "symbol": "BNB",
      "nameKo": "바이낸스스마트체인",
      "nameEn": "Binance Smart Chian",
      "status": "ACTIVATED",
      "type": "DEFAULT",
      "contractAddress": null,
      "decimals": 8,
      "iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png",
      "deleteWalletMinAmount": "0.00010000000000000000",
      "createdDate": "2021-09-20T07:40:18.511Z",
      "modifiedDate": "2021-12-23T06:13:37.636Z"
    },
    "feeInjectionTransaction": null,
    "feeInjectionFee": null,
    "gatheringTransaction": {
      "idx": 8965,
      "uuid": "32c266f2-b395-4e82-b737-670ae7767600",
      "type": "GATHERING",
      "txid": "5cfc6af79bbfe2bef92c96e148bf73bffbdacd84a0d2b2468f1ac7cd57cde666",
      "fromAddress": "tb1q493qlgvg7qfy3k7pan5nv006chxrz2dxmunthr",
      "toAddress": "tb1quzmru5wx8d6y96f0mv508lycyemq8vydcly6hf",
      "amount": "0.00005971000000000000",
      "usedFee": "0.00049029000000000000",
      "nonce": null,
      "blockHeight": "2133581",
      "serialized": null,
      "memo": null,
      "status": "FINALIZED",
      "outputIndex": null,
      "createdDate": "2021-12-29T08:10:00.262Z",
      "modifiedDate": "2021-12-29T08:20:00.000Z",
      "unfinalizedDate": "2021-12-29T08:20:00.000Z",
      "finalizedDate": "2021-12-29T08:20:00.000Z",
      "failedDate": null,
      "coin": {
        "idx": 1,
        "symbol": "BNB",
        "nameKo": "바이낸스스마트체인",
        "nameEn": "Binance Smart Chain",
        "status": "ACTIVATED",
        "type": "DEFAULT",
        "contractAddress": null,
        "decimals": 8,
        "iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png",
        "deleteWalletMinAmount": "0.00010000000000000000",
        "createdDate": "2021-09-20T07:40:18.511Z",
        "modifiedDate": "2021-12-23T06:13:37.636Z"
      }
    },
    "gatheringFee": {
      "idx": 151,
      "gasLimit": null,
      "gasPrice": "277.00000000000000000000",
      "unit": "satoshi",
      "schedulerData": null,
      "createdDate": "2021-12-29T08:09:03.769Z",
      "modifiedDate": "2021-12-29T08:09:03.769Z"
    }
  }
]

3. Checking with Webhooks

When the gathering to the main address is finished, a gathering webhook will be sent. You can check the gathering status from the webhook. For more information about how to use webhooks and their data structure, check the 'Webhook' page.






Withdrawal

Withdrawal Process

Assets must be withdrawn from the main address to transfer them from a custodial wallet to the outside. An asset cannot be transferred outside from the child address.

  1. Request withdrawal.
  2. Generate transaction.
  3. Calculates the optimal fees and propagates the transactions.
  4. Withdrawal is completed when the transactions are confirmed in the blocks.


Withdrawal Status

Unlike a deposit, a withdrawal is finalized(FINALIZED) at the moment when the transaction is included in the blocks.

Status nameDescription
AWAITING_DECISIONAwaiting withdrawal approval
REJECTEDWithdrawal is denied
AWAITING_WITHDRAWALApproved and awaiting withdrawal
PENDINGWithdrawal transaction is generated
FINALIZEDWithdrawal transaction is included in the blocks
FAILEDWithdrawal transaction failed


Withdraw

You can request a withdrawal from the main address to the outside by calling the Request Withdrawal API. The uuid value will be returned when the withdrawal request is successful. The value can be used to access the withdrawal process.

Response example

{
  "uuid": "18012e3f-07f3-45ec-862b-f020c0ca935a"
}


Withdrawal Confirmation

1. Checking from the Console

You can check the withdrawal status from [Transaction History] on the console. AWAITING_WITHDRAWAL or PENDING withdrawals are displayed as ‘Processing’, and FINALIZED withdrawals are displayed as ‘Completed’.


2. Checking with API

You can check the progress of a specific withdrawal transaction by calling the Access Withdrawal Transaction Information API.

Response example

{
  "idx": 490,
  "uuid": "07efdcb2-b3fd-4fe7-bf47-c0b460b289e3",
  "fromAddress": "0x71b5De2970A32eEf6362AE7Bc3B73103b4392bB0",
  "toAddress": "0x295909dC67B76f936BD4119aDd877088602cCaD3",
  "amount": "2.00000000000000000000",
  "memo": null,
  "requestId": "25",
  "type": "API",
  "description": "",
  "requiredApprovalCount": 1,
  "useApiAutoApproval": true,
  "status": "SENT",
  "createdDate": "2022-01-25T09:25:02.383Z",
  "modifiedDate": "2022-01-25T09:25:10.000Z",
  "rejectedDate": null
}

3. Checking with Webhooks

When the withdrawal from the main address is finished, a withdrawal webhook will be sent. You can check the withdrawal status from the webhook. For more information about how to use webhooks and their data structure, check the Webhook page.






Balance Access Criteria

You can check the balance of the asset stored in a specific address by calling the Access Address Balance API. The accessed balances are specified into total balances and liquid balances.

  • Total balance is all assets with a confirmation of 1 or above.
  • Liquid balance refers to the assets that can be gathered or withdrawn. The liquid balance of a child address represents the assets that can be gathered, while the liquid balance of the main address represents the assets that can be withdrawn.





Fees

Estimated Fees

Estimated fees are calculated by multiplying the gas price’s FASTEST value and the gas limit. Octet sets the gas limit of BNBs to 21,000. The gas limit for tokens is set to 100,000 since it varies depending on how the tokens are implemented. The gas limit is the maximum value, so the actual gas usage could be less than that, and the fees are charged for the actual gas usage.

Estimated Fees = Gas Limit x Gas Price

Transaction Fees

You can access the gas price in real-time by calling the Fee/Gas API. Fees charged for a transaction are calculated by multiplying the gas price’s FASTEST value and the amount of used gas.

Transaction Fees = Usage by Txn x Gas Price





Faucet

In the case of the testnet, you must obtain a testing BNB from the faucet website and deposit it. When an actual BNB is deposited in the testnet, it will not be recognized.