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.
- blockchainType - Indication of which blockchain you wish the transaction to be built for. Currently we support ethereum only.
Sample value: "ethereum"
- fromCurrencyId - The currency ID of the token you wish to convert tokens from (i.e., the Origin Token).
Sample value: "5937d635231e97001f744267"
- toCurrencyId - The currency ID of the token you wish to convert tokens to (i.e., the Destination Token).
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"
- 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"
- 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: "0x03733d509f60a33f1b86856560256351f23e5531"
API URL (POST)
How to send the "Required Data"?
Include the values in the body of the API call.
After calling the "Convert" API with the correct values, you will receive the transaction that can now be sent to the relevant blockchain.
- 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.
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