Binance Smart Chain Documentation

Introduction

This API allows you to interact with the Binance Smart Chain including Binance COIn and BEP-20 tokens. If you ever looked for a possibility to automate token or BNB payments this is the right place.
You still have no idea for real use cases? Let me give you some examples: Accept your own BEP-20 token as payment method for your shop, distribute airdrop tokens of your ICO, convert your site currency to a token that can be traded on exchanges and many more.
There are a lot of use cases which are not only limited to sending tokens and BNB but also receiving them. You could even create a secure wallet for your token which only the wallet owner has access to.

Postman

Postman collection and documentation will follow soon...

Tutorials

We wrote a few step-by-step tutorials with example code in PHP that might help you to work with our solution. Currently there is one tutorial for every request type.
Address Requests: Create addresses
Transaction Requests: Send transactions
Info Requests: Get balances
IPN/Subscription Requests: Create IPNs/Subscriptions

API Requests

All Requests to our API are made in JSON format using HTTP POST. We will also return everything in JSON format. The Europe API endpoint is located at https://eu.bsc.chaingateway.io/v1/{function}.

API Key

You can get your personal API Key from your account dashboard. It is used by us to determine who is accessing the API and to count the requests by that account. There are 2 possibilities to use it in your requests:

  1. Add it in the HTTP header as
    'Authorization: q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m'. This is very secure and may be the only option in future versions.
  2. Add it to the JSON body in your request, like
    "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m". This is not recommended!
Please do not share your api key! If you did so by mistake, immediately regenerate it in your account panel!

Parameters

Binancecoin Address

This is an Binancecoin address, which has 0x in front and 40 hexadecimal characters after it. CAUTION: If you send tokens, the receiving address must be BEP-20 compatible. So please don't use an exchange address.

Contract Address

The contract address is the binance smart chain contract address of the BEP-20 token you want to use. It has the same format as normal Binancecoin addresses.

Amount

We want amounts to be in normal decimal format and as string. If you want to send 2.5 BNB, use "2.5". If you want to send 1 million tokens, use "1000000". If you are not sure how many decimals a token has, you can use the getToken function. We decided to use amounts in string format to support up to 18 decimals with perfect precision.

Password

Whenever you create a new Binancecoin address, you need to specify a password for it. This password is used for all transactions you are doing with this address. We don't save this password on our end, so please don't lose it.

Security

Our API is very secure. The Nodes are not hosted on the same machine as the API endpoint. Also, they are not using the standard port and have a few proxies running in front. They are protected with a few firewalls, ddos protection and breach detection, too. We also have protected our endpoint and nodes against bruteforce. Sensitive data, especially keystores are being saved only with really strong and military proof encryption. But even if someone would get control over our systems, your funds would still be save. Like you can see above, every Binancecoin address needs a password for transactions. Without it, the funds can't be accessed. This means our system is as secure as your application. If you don't secure your system and don't store the passwords in a safe way, attackers may be able to steal funds from your addresses. (They would still need your API Key however)

Fees

We are charging on a monthly plan basis if you use our API. You can see the exact pricing and request amounts here. There are also transaction fees, which go to the miners to include your transaction in a block. So please make sure there are always enough Binance coins on the address you are sending tokens or BNB from. The exact fee which is used is determined by the average gas fee at that time (If not specified otherwise).

getToken

Endpoint:
https://eu.bsc.chaingateway.io/v1/getToken

HTTP Method: POST


Parameter Explanation Example
contractaddress Binance smart chain contract address of the BEP-20 token 0x5b86a33f0c232fe909eb4602a9d039072869d915
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "name": "Bitfranken", "symbol": "BIFRA", "decimals": 2, "supply": 76507131570}

getLastBlockNumber


Endpoint:
https://eu.bsc.chaingateway.io/v1/getLastBlockNumber

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "blocknumber": 6496847}

getGasPrice

Endpoint:
https://eu.bsc.chaingateway.io/v1/getGasPrice

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "gasprice": 3}

getExchangeRate

Endpoint:
https://eu.bsc.chaingateway.io/v1/getExchangeRate

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
currency eur or usd eur

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m", "currency": "eur"}

Example Response JSON:
{"ok": true, "currency": "eur", "rate": 263.28}

getBinancecoinBalance

Endpoint:
https://eu.bsc.chaingateway.io/v1/getBinancecoinBalance

HTTP Method: POST


Parameter Explanation Example
binancecoinaddress Binance coin address you want to get the balance of 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "balance": "0.456"}

getTokenBalance

Endpoint:
https://eu.bsc.chaingateway.io/v1/getTokenBalance

HTTP Method: POST


Parameter Explanation Example
contractaddress Binance smart chain contract address of the BEP-20 token 0x5b86a33f0c232fe909eb4602a9d039072869d915
binancecoinaddress Binance coin address you want to get the balance of 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "balance": "0.456"}

getTransaction

Endpoint:
https://eu.bsc.chaingateway.io/v1/getTransaction

HTTP Method: POST


Parameter Explanation Example
txid (Optional) Transaction id/hash of Binancecoin or token transfer 0x9800b1a53ce3aae4652b7e4b69a1cdaaab47ecd36f91558590f0436deb05669f
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"txid":"0x9800b1a53ce3aae4652b7e4b69a1cdaaab47ecd36f91558590f0436deb05669f", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok":true,"bep-20":false,"txid":"0x344eee4cbcca4978557a86912199dd3c127897a9b144d456c1431a3567705f1c","blockhash":"0x6fc87395b11279295d6c99561be167e7f98c76da8666a1375efe2ceed88ea232","blocknumber":5564697,"txindex":277,"from":"0x33d5a7f388b1aa58a935ece946cb45cfc8505bdf","to":"0x734be7ac1efbe09aa13ed54b4935016a80214d12","amount":"0.003043132108765433","gasprice":10,"gas":21000,"confirmations":53947}

listAddresses

Endpoint:
https://eu.bsc.chaingateway.io/v1/listAddresses

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok":true,"addresses":[{"binancecoinaddress":"0xa1f36016221d48ce7f15cde7b826a4fbe09bacce"}]}

importAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/importAddress

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
filename Filename of the keystore file UTC--2020-05-01T12-30-12.020Z--4fb45889cd2d3348348e39c613c41bf1dc43760a
content Content of keystore file {"version":3,"id":"f0449f3f-1ef2-5fb9-bf09-20bb72c47167","address":"4fb45889cd2d3348348e39c613c41bf1dc43760a","crypto":{"ciphertext":"027fbbe9d7b91b1a4a3afddcb27a07ac5e7fff550fd167452a6345a961f21a4d","cipherparams":{"iv":"a2b3022a9d7d76ade60dd70e5405cc09"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"fd84f455da4ad1325cf5bc7beb06bf3052919278c76373a67507aaa68bcebab3","n":131056,"r":6,"p":1},"mac":"d46d36b6facd1f3f5549f01cb5c87de0c01b68b6445410259128c52d515a7b6d"}}
password Password to access the keystore (won't be stored unencrypted) padN39QkRA2hJ

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m", "filename": "UTC--2020-05-01T12-30-12.020Z--4fb45889cd2d3348348e39c613c41bf1dc43760a", "content": {"version":3,"id":"f0449f3f-1ef2-5fb9-bf09-20bb72c47167","address":"4fb45889cd2d3348348e39c613c41bf1dc43760a","crypto":{"ciphertext":"027fbbe9d7b91b1a4a3afddcb27a07ac5e7fff550fd167452a6345a961f21a4d","cipherparams":{"iv":"a2b3022a9d7d76ade60dd70e5405cc09"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"fd84f455da4ad1325cf5bc7beb06bf3052919278c76373a67507aaa68bcebab3","n":131056,"r":6,"p":1},"mac":"d46d36b6facd1f3f5549f01cb5c87de0c01b68b6445410259128c52d515a7b6d"}}, "password": "padN39QkRA2hJ"}

Example Response JSON:
{"ok":true,"binancecoinaddress": "0x4fb45889cd2d3348348e39c613c41bf1dc43760a", "filename": "UTC--2020-05-01T12-30-12.020Z--4fb45889cd2d3348348e39c613c41bf1dc43760a"}

exportAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/exportAddress

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
binancecoinaddress EBinancecoin address you want the keystore of 0x4fb45889cd2d3348348e39c613c41bf1dc43760a
password Password to access the keystore padN39QkRA2hJ

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m", "binancecoinaddress": "0x4fb45889cd2d3348348e39c613c41bf1dc43760a", "password": "padN39QkRA2hJ"}

Example Response JSON:
{"ok":true, "filename": "UTC--2020-05-01T12-30-12.020Z--4fb45889cd2d3348348e39c613c41bf1dc43760a", "content": {"version":3,"id":"f0449f3f-1ef2-5fb9-bf09-20bb72c47167","address":"4fb45889cd2d3348348e39c613c41bf1dc43760a","crypto":{"ciphertext":"027fbbe9d7b91b1a4a3afddcb27a07ac5e7fff550fd167452a6345a961f21a4d","cipherparams":{"iv":"a2b3022a9d7d76ade60dd70e5405cc09"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"fd84f455da4ad1325cf5bc7beb06bf3052919278c76373a67507aaa68bcebab3","n":131056,"r":6,"p":1},"mac":"d46d36b6facd1f3f5549f01cb5c87de0c01b68b6445410259128c52d515a7b6d"}}}

subscribeAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/subscribeAddress

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
binancecoinaddress The address you want to watch 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
contractaddress (Optional) Contractaddress of the Token you want to watch (Will watch Binance coin by default) 0x5b86a33f0c232fe909eb4602a9d039072869d915
url The URL you want to receive notifications on. The script on the url should run below 10 seconds, otherwise the notification will fail! Also, please return {"ok": true} in JSON format and header to signal our API that the IPN has been received successfully. https://yoururl.com/ipnreceiver.php

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m","binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "url": "https://yoururl.com/ipnreceiver.php"}

Example Response JSON:
{"ok":true, "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "url": "https://yoururl.com/ipnreceiver.php"}

UnsubscribeAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/unsubscribeAddress

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
binancecoinaddress The address you are watching 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
contractaddress (Optional) Contractaddress of the Token you are watching (Will unwatch Binance coin by default) 0x5b86a33f0c232fe909eb4602a9d039072869d915
url The URL you receive notifications on https://yoururl.com/ipnreceiver.php

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m","binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "url": "https://yoururl.com/ipnreceiver.php"}

Example Response JSON:
{"ok":true, "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "url": "https://yoururl.com/ipnreceiver.php", "deleted": true}

listSubscribedAddresses

Endpoint:
https://eu.bsc.chaingateway.io/v1/listSubscribedAddresses

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok":true,"ipns":[{"binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "url": "https://yoururl.com/ipnreceiver.php"}]}

listFailedIPNs

Endpoint:
https://eu.bsc.chaingateway.io/v1/listFailedIPNs

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok":true,"failed_ipns":[{"id":"182659","timestamp":"2019-12-18 17:14:36","binancecoinaddress":"0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "contractaddress":null,"amount":"0.0277", "url":"https:\/\/yoururl.com/ipnreceiver.php","action":"withdraw"}]}

resendFailedIPN

Endpoint:
https://eu.bsc.chaingateway.io/v1/resendFailedIPN

HTTP Method: POST


Parameter Explanation Example
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
id ID of the IPN to send again 182659

Example Request JSON:
{"apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m", "id": 182659}

Example Response JSON:
{"ok":true, "id": 182659}

newAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/newAddress

HTTP Method: POST


Parameter Explanation Example
password Password which is being used for transactions. DON'T LOSE IT padN39QkRA2hJ
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"password": "padN39QkRA2hJ", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "password": "padN39QkRA2hJ"}

deleteAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/deleteAddress

HTTP Method: POST


Parameter Explanation Example
binancecoinaddress Binancecoin address you want to renew 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
password The Password of the Binancecoin address padN39QkRA2hJ

Example Request JSON:
{"binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m", "password": "padN39QkRA2hJ"}

Example Response JSON:
{"ok": true, "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "deleted": true}

sendBinancecoin

Endpoint:
https://eu.bsc.chaingateway.io/v1/sendBinancecoin

HTTP Method: POST


Parameter Explanation Example
from Binancecoin address you want to send from 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
to Binancecoin address you want to send to 0xef4943d727e34280a2efa0b3352dfd61f508ee48
password Password of the Binancecoin address you want to send from padN39QkRA2hJ
amount Amount of BNB you want to send 0.05
gas (optional) gas amount. Default is 21000 21000
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"from": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "to": "0xef4943d727e34280a2efa0b3352dfd61f508ee48", "password": "padN39QkRA2hJ", "amount": "0.05", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m", "gas": 21000}

Example Response JSON:
{"ok": true, "txid": "0xcff06775098019d18f7bab6a350c18e86f89399d b63cbce5269104e6c9a79499", "from": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "to": "0xef4943d727e34280a2efa0b3352dfd61f508ee48", "amount": "0.05"}

clearAddress

Endpoint:
https://eu.bsc.chaingateway.io/v1/clearAddress

HTTP Method: POST


Parameter Explanation Example
binancecoinaddress Binancecoin address you want to clear 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
newaddress Binancecoin address you want to send all BNB to 0xef4943d727e34280a2efa0b3352dfd61f508ee48
password Password of the Binancecoin address you want to send from padN39QkRA2hJ
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m

Example Request JSON:
{"binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "newaddress": "0xef4943d727e34280a2efa0b3352dfd61f508ee48", "password": "padN39QkRA2hJ", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "txid": "0xcff06775098019d18f7bab6a350c18e86f89399d b63cbce5269104e6c9a79499", "binancecoinaddress": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "newaddress": "0xef4943d727e34280a2efa0b3352dfd61f508ee48", "amount: "0.00980226", "gas": "0.000063", "total": "0.00986526"}

sendToken

Endpoint:
https://eu.bsc.chaingateway.io/v1/sendToken

HTTP Method: POST

Parameter Explanation Example
contractaddress Binance smart chain contract address of the BEP-20 token 0x5b86a33f0c232fe909eb4602a9d039072869d915
from Binancecoin address you want to send from 0xa1f36016221d48ce7f15cde7b826a4fbe09bacce
to Binancecoin address you want to send to 0xef4943d727e34280a2efa0b3352dfd61f508ee48
password Password of the Binancecoin address you want to send from padN39QkRA2hJ
amount Amount of tokens you want to send 0.05
apikey Your API Key q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m
identifier (Optional) Prevents double sending. Can be any string below 32 characters. CN562
gasprice (Optional) Gas Price in GWEI 5
gas (Optional) gas limit 90000

Example Request JSON:
{"contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "from": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "to": "0xef4943d727e34280a2efa0b3352dfd61f508ee48", "password": "padN39QkRA2hJ", "amount": "0.05", "apikey": "q9PdaWuD4j6DK6vsUgehhL8pgarSrS9m"}

Example Response JSON:
{"ok": true, "txid": "0xcff06775098019d18f7bab6a350c18e86f89399d b63cbce5269104e6c9a79499", "contractaddress": "0x5b86a33f0c232fe909eb4602a9d039072869d915", "from": "0xa1f36016221d48ce7f15cde7b826a4fbe09bacce", "to": "0xef4943d727e34280a2efa0b3352dfd61f508ee48", "amount": "0.05"}