Trading is the core value proposition to users of Bancor Network. The easiest way to trade is to use the Bancor Dapp. This is the recommended entry point to trading on Bancor for new users.
Other ways to trade via Bancor include the Bancor Widget, which can be embedded by third parties on their sites, and via smart contract interface, where a third party developer has integrated Bancor into their smart contract.
If you want to trade directly on the
BancorNetwork contract, Etherscan's web UI makes it quite easy. Additionally, this guide will be helpful for developers looking to interface with Bancor contracts via their own smart contract.
Bancor contracts are regularly upgraded so the
BancorNetwork address may change over time. To find the latest address:
Navigate to the ContractRegistry contract on Etherscan
Read Contract section, execute the getAddress function with the following parameter:
_contractName: 0x42616e636f724e6574776f726b. This is the bytes32 representation of "BancorNetwork"
This return value is the address of the
BancorNetwork contract. Save this value for Step #3
A key input for any trade on Bancor is the conversion path. The conversion path is the map between liquidity pools that allows for any token on Bancor to be exchanged for any other.
We recommend using the Bancor SDK for generating the most efficient path between two tokens. Reference the
getPathAndRate function documented on the SDK Github. This API call will provide you with the conversion path and expected exchange rate of the trade. You'll need both of these inputs for Step #3.
If you'd like to generate a conversion path on-chain, the
conversionPath function on the BancorNetwork contract provides a good approximation of the best path. This function is well-documented in the
Trading with Bancor guide in the Developer Quick Start.
Navigate to the Etherscan page of the contract address we queried for in Step #1 and head to the
Write Contract view
If you're exchanging ether for another token, you'll be using the
convert function (#25)
If you're exchanging one token for another token, you'll be using the
claimAndConvert function (#19)
You have the
_path parameter from Step #2 and you can use the
rate return value from
getPathAndRate as a reference point for how to determine the
Execute the correct function with the relevant inputs