Creating a Local Binance DEX Testnet
Using a local dev environment provides needed testing flexibility
The Binance public testnet at https://testnet-explorer.binance.org is useful for testing DApps and other Binance-based applications. However, limitations include:
Issuing test tokens costs 500BNB
Listing test tokens costs 1000 BNB
Testnet Faucet only issues 200BNB once per address. If you want to test a full scale application you spend a lot of time acquiring and transferring tokens.
Creating a local dev testnet provides the opportunity to fully test an application without paying fees or visiting the faucet. We provide the necessary steps below.
Following the tutorial, there are instructions to move these commands to Docker.
Run Binance Testnet Node
1) Download Required Binaries
All binaries are stored in the official GitHub repository (https://github.com/binance-chain/node-binary). Required are the latest versions of testnet fullnode and testnet cli.
In this tutorial, we use the following executables:
fullnode/testnet/0.6.2/linux/bnbchaind
cli/testnet/0.6.2/linux/tbnbcli
Install Git-LFS (used by the repository) and execute the following:
If you experience this error: "Skipping object checkout, Git LFS is not installed" run git lfs install
again and rerun the git lfs pull command.
2) Generate Configs
Create all required configs for testnet validator, genesis block, etc
--acc-prefix
defines used binance BECH32 addresses prefix ()tbnb
used for consistency with public testnet--v
denotes an initial number of validators for the Binance Chain, put it1
for simplicity.
Generated configs will be located in the ./mytestnet/node0/gaiad/config
directory. Important files are app.toml
, config.toml
, genesis.json
.
If needed, modify parameters in these files (for example settingBEP12Height = 1
in app.toml
will allow BEP12 transactions from the first block).
3) Start Validator Full Node
All necessary files (chain configs and validator account keys) are located in the./mytestnet/node0/gaiad
directory.
1) Start validator node
Validator node should start generating new blocks, which can be observed through the terminal.
The error message "Couldn't connect to any seeds module=p2p" in the terminal window is expected behavior.
2) Node validator automatically provides Node-RPC service at http://localhost:26657
. Check it out using /status
sub-url from a second terminal window.
4): Create a Prefunded Address
At the moment, a single validator account exists in the network. Let’s create another one, and prefund it for future use.
Note the printed account address. We will transfer BNB tokens from the validator account to our newly created one.
--to
previously generated address--from
validator node key name (by defaultnode0
)--home
- directory with validator keystore files12345678
- default password for validator keystore.
Additional Actions
Now you can continue with regular binance dex actions. For example, issue a new token:
Accessible HTTP API Services
In regular binance mainnet and testnet, three different APIs are available:
Node RPC - in our Binance-Dev network it is accessible at
http://localhost:26657
Api-server - in our testnet, instantiate by running
./tbnbcli api-server --chain-id Binance-Dev
HTTP-API - api of the accelerated node is not accessible. There is no way to make your accelerated node, so this api will not work. However, some paths can be covered by the first two api services, or emulated if necessary.
Moving to Docker
Dockerfile for fetching binaries and updating configs
Assume that image built from this file is called testnet-binaries
Dockerfile for Validator Node
Dockerfile for API-Server
docker-compose.yml
Last updated