Using A Swap Contract for DigixDAO Badges — From Attores
Our next contract in line is the contract for swapping DigixDAO badges for Ether. We have open sourced the code for an escrow Swap Contract for the Digix Crowdsale badges. You can find it at this link: https://github.com/gaurangtorvekar/DGD-Badge-Swap
Checksum current version 0.1 / md5:b98bacdd5ac73013764a10208d2a6a6a
Older versions will have a checksum at the bottom of the page.
The unique thing about this particular swap contract is that, none of the exchanges currently give you the ability to exchange the badges. Most of them can only exchange the tokens.
Swapping the badges using the contract is a 3-step process.
- Create a Swap contract with your desired price
- Transfer some badges to the swap contract
- Get the other party to send Ether to this contract
Step 1 — To create a Swap contract
In your Mist (Ethereum-Wallet), go to Contracts > Deploy New Contract
In the text box for ‘Solidity Contract Source Code’, copy paste the code from the file DGD_badge_swap.sol from the GitHub link: https://github.com/gaurangtorvekar/DGD-Badge-Swap
Under amount, put in the amount of 0.01 to 0.05 for gas costs of the contract execution. (under the current code, the contract won’t send you back any remaining ether, we are unsure of the gas you will need as you may have many or few transactions. You may need to top up.)
On the right hand panel, in the ‘Constructor parameters’, enter the token address of the DGD Badge contract, which is — 0x54bda709fed875224eae569bb6817d96ef7ed9ad
Morden Testnet DGD Badge address: 0x40cd4bd518f130eed030693d933b5e127dcd046d
In ‘send ether to’ — beneficiary, put any of your own Wallet addresses where you want to receive the Ether.
Then enter the price you want for your badge(please note that this price is in Finney. 1 Ether = 1000 Finney, so if you want 10.50 ether for your Badge you would enter 10500)
The ‘expiration in days’ field is in case no one matches your order, you’ll get the token back. Any Badges or ether sent after this date will not be accepted by the contract. In this example, the contract will expire in 4 days if there is no buyer and the badge will return to the beneficiary.
Step 2 — Transfer badges to this Swap Contract
You can start watching the DGD badge contract by copy pasting the abi code Badge.json from this link: https://gist.githubusercontent.com/tymat/caa79528615ad600f216e2e6f6b6e3c3/raw/27a10cf074827d6a0162996b5a6f59c19dd879fa/Badge.json
and putting the badge address: 0x54bda709fed875224eae569bb6817d96ef7ed9ad
Morden Testnet DGD Badge address: (be very careful not to use the testnet address on a livenet contract!!!) 0x40cd4bd518f130eed030693d933b5e127dcd046d
You should also watch the token so that you can send it using the send feature in mist.
Transfer the badges from YOUR address which owns the tokens to the Swap Contract you just created.
Once you have transferred the badges to your Swap Contract, you should be able to see those in the ‘Balance Of’ section of the token contract when you enter the swap contract address into it.
Step 3 — Get Ether from the second party
Now you can ask the buyer to send Ether to this Swap contract. This sender will get the appropriate amount of badges and you will get the Ether in your ‘beneficiary’ account that you entered earlier
Visit Attores.com for more contracts, and our upcoming Smart Contracts as a Service platform.