********************

Please note that this API will be terminated as of September 1st, 2019. The new Convert API for Ethereum, EOS and Cross Convert can be found here.

********************

In order to build a quickConvert transaction and submit it to the blockchain, you can use our "Convert" API. This will allow you to easily create the correct transaction using basic information required to successfully execute it.

How will this work?

You will need to collect the relevant information needed and send it to our "Convert" API. In return, you will receive the transaction format and data string that is required from the relevant blockchain.

Required Data:

blockchainType - Indication of which blockchain you wish the transaction to be built for. Currently we support ethereum only.

Sample value: "ethereum"

Sample value: "ethereum" fromCurrencyId - The currency ID of the token you wish to convert tokens from (i.e., the Origin Token).

Sample value: "5937d635231e97001f744267"

Sample value: "5937d635231e97001f744267" toCurrencyId - The currency ID of the token you wish to convert tokens to (i.e., the Destination Token).

Sample value: "59d745ff90509add31e9db14"

Sample value: "59d745ff90509add31e9db14" amount - The amount of tokens you wish to convert. This value needs to be in the smallest possible unit (Wei), integer only.

Sample value: "100000000000000000"

Sample value: "100000000000000000" minimumReturn - The minimum amount of tokens you are willing to accept in return for the transaction. The transaction will check the amount of units the wallet is expected to receive against the minimum return value. If you are expected to receive fewer units, the transaction will fail. We recommend setting this value to 2% under the expected return amount.

Example: If the conversion is expected to return 100 units back, minimum return should be set to (100x0.98)=98 units. This value needs to be in the smallest possible unit (Wei), integer only.

Sample value: "1"

Example: If the conversion is expected to return 100 units back, minimum return should be set to (100x0.98)=98 units. This value needs to be in the smallest possible unit (Wei), integer only. Sample value: "1" ownerAddress - The address of the wallet executing the transaction. It must be the address of the wallet that contains the "Origin Tokens" that you wish to convert. The converter will return the "Destination Tokens" back to this address at the end of the process.

Sample value: "0x5f7a009664b771e889751f4fd721adc439033ecd"

API URL (POST)

https://api.bancor.network/0.1/currencies/convert

How to send the "Required Data"?

Include the values in the body of the API call.

Example:

{

"blockchainType":"ethereum",

"fromCurrencyId":"5937d635231e97001f744267",

"toCurrencyId":"59d745ff90509add31e9db14",

"amount":"100000000",

"minimumReturn":"1",

"ownerAddress":"0x5f7a009664b771e889751f4fd721adc439033ecd"

}

API Response:

After calling the "Convert" API with the correct values, you will receive the transaction that can now be sent to the relevant blockchain.

Values:

from - The owner address

to - The relevant currency converter code. This converter will trigger the conversion process.

data - the transaction code for the relevant blockchain.

value - The indicated amount to convert.

gasPrice - The maximum gas price allowed to ensure quick processing. Increasing this value above the returned amount will cause the transaction to fail.

nonce - the wallet relevant transaction number. This value will ensure that this transaction will be the next one executed on this wallet.

gasLimit - the amount of units required to calculate the transaction successfully. Changing this value may cause the transaction to fail.

Example response:

{

"data": [

{

"from": "0x03733d509f60a33f1b86856560256351f23e5531",

"to": "0xb626a5facc4de1c813f5293ec3be31979f1d1c78",

"data": "0xf0843ba90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000007000000000000000000000000c0829421c1d260bd3cb3e0f06cfe2d52db2ce3150000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c0000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c000000000000000000000000d7eb9db184da9f099b84e2f86b1da1fe6b305b3d000000000000000000000000d7eb9db184da9f099b84e2f86b1da1fe6b305b3d000000000000000000000000d7eb9db184da9f099b84e2f86b1da1fe6b305b3d0000000000000000000000006810e776880c02933d47db1b9fc05908e5386b96",

"value": "0x16345785d8a0000",

"gasPrice": "0x77359400",

"nonce": "0x1c6",

"gasLimit": "0x9dc62"

}

]

}

Hashed Values

Bancor uses a prioritization mechanism to enable transactions to be executed in the correct and valid order. Changing any of these values will cause the transaction to fail:

Block number - we initiate a transaction life of X blocks. Meaning, from the moment you create the transaction you have X amount of blocks to execute it. Executing it after the transaction lifetime will cause the transaction to fail. Gas price - the gas price received is part of the transaction's hard coded values. Changing the gas price will cause the transaction to fail. User address - transaction is limited to a specific user. Nonce - transaction is limited to a specific nonce.

Send the transaction to the blockchain:

At this stage, you have the correct transaction created by our server and you will need to transmit it into the relevant blockchain.

Ethereum format can be found here: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction

-----

Keep in mind:

Bancor API is currently in alpha and may experience downtime, be upgraded, or suffer from high latency.

We offer several developer APIs, for more information please visit our API Documentation