Bancor Protocol Contracts
Branch: master
Clone or download
Latest commit 35a5cb2 Feb 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts newly compiled contracts Jan 29, 2019
solidity additional network test Jan 29, 2019
.gitattributes Configure Solidity syntax highlighting Jun 26, 2018
.gitignore added formula python tests Jun 19, 2017
.npmrc disabled package-lock.json Jul 24, 2017 updated conversion version and changelog Jan 29, 2019
LICENSE Update LICENSE Oct 27, 2017 Whitepaper link Feb 4, 2019
package.json 0.4.6 Jan 29, 2019

Bancor Protocol Contracts v0.4 (beta)

Bancor is a decentralized liquidity network that provides users with a simple, low-cost way to buy and sell tokens. Bancor’s open-source protocol empowers tokens with built-in convertibility directly through their smart contracts, allowing integrated tokens to be instantly converted for one another, without needing to match buyers and sellers in an exchange. The Bancor Wallet enables automated token conversions directly from within the wallet, at prices that are more predictable than exchanges and resistant to manipulation. To convert tokens instantly, including ETH, EOS, DAI and more, visit the Bancor Web App, join the Bancor Telegram group or read the Bancor Protocol™ Whitepaper for more information.


The Bancor protocol represents the first technological solution for the classic problem in economics known as the “Double Coincidence of Wants”, in the domain of asset exchange. For barter, the coincidence of wants problem was solved through money. For money, exchanges still rely on labor, via bid/ask orders and trade between external agents, to make markets and supply liquidity.

Through the use of smart-contracts, Smart Tokens can be created that hold one or more other tokens as connectors. Tokens may represent existing national currencies or other types of assets. By using a connector token model and algorithmically-calculated conversion rates, the Bancor Protocol creates a new type of ecosystem for asset exchange, with no central control. This decentralized hierarchical monetary system lays the foundation for an autonomous decentralized global exchange with numerous and substantial advantages.


Bancor is a work in progress. Make sure you understand the risks before using it.

The Bancor Standards

Bancor protocol is implemented using multiple contracts. The main ones are SmartToken and BancorConverter. BancorConverter is responsible for converting between a token and its connectors. SmartToken represents a converter aware ERC-20 compliant token.

The Smart Token Standard


Those will allow creating a Bancor compliant token while keeping dependencies at a minimum. In addition, it allows an owning contract to extend its functionality by giving the owner full control.



First and foremost, a Smart Token is also an ERC-20 compliant token. As such, it implements both the standard token methods and the standard token events.


Note that these methods can only be executed by the token owner.


function issue(address _to, uint256 _amount)

Increases the token supply and sends the new tokens to an account.


function destroy(address _from, uint256 _amount)

Removes tokens from an account and decreases the token supply.


function disableTransfers(bool _disable)

Disables transfer/transferFrom functionality.



event NewSmartToken(address _token)

Triggered when a smart token is deployed.


event Issuance(uint256 _amount)

Triggered when the total supply is increased.


event Destruction(uint256 _amount)

Triggered when the total supply is decreased.

The Bancor Converter Standard

The following section describes standard functions a bancor converter can implement.


Those will allow dapps and wallets to buy and sell the token.

The most important here is convert.




function connectorTokenCount() public constant returns (uint16 count)

Gets the number of connector tokens defined for the token.


function connectorTokens() public constant returns (address[] connectorTokens)

Gets an array of the connector token contract addresses.


function connectors(address _connectorToken) public constant

Gets the connector token details.


function convert(address _fromToken, address _toToken, uint256 _amount, uint256 _minReturn)

converts a specific amount of _fromToken to _toToken The conversion will only take place if it returns a value greater or equal to _minReturn.



event Conversion(address indexed _fromToken, address indexed _toToken, address indexed _trader, uint256 _amount, uint256 _return, uint256 _currentPriceN, uint256 _currentPriceD);

Triggered when a conversion between one of the convertible tokens takes place.


Tests are included and are run using truffle & ganache


  • Node.js v7.6.0+

To run the test:

  • Use npm install in order to install all required packages.
  • Use npm test 1 in order to run truffle-test or npm test 2 in order to run solidity-coverage.



Bancor Protocol is open source and distributed under the Apache License v2.0