This repository shows some examples, how other smart contracts can interact with the E-money Token on the ioCash platform.
npm install
npx truffle compile
Only whitelisted accounts are able to operate with the ioCash platform. The private key of one of those accounts has to be configured in the file truffle-config.js
:
const PRIVATE_KEY = '0xABCD....';
A smart contract should be able to transfer tokens on behalf of an account that is registered on ioCash.
- Start truffle console
npx truffle console --network telsius
- Get an instance of the E-Money Token with its current address:
emoney = await EmoneyToken.at(ADDRESS_EM_TOKEN)
- Deploy the demo smart contract with the current address of the E-money Token
demoTransfer = await TransferTokens.new(emoney.address)
- Authorize the deployed smart contract to do transfers on the registered accounts' behalf:
emoney.authorizeTransferOperator(demoTransfer.address)
- Call the demo smart contract to do a transfer on behalf of
msg.sender
:demoTransfer.doTransfer(TRANSFER_ID, TO_ADDRESS, AMOUNT_TO_TRANSFER)
A smart contract should be able to be a notary for a hold that was created on ioCash.
-
Start truffle console
npx truffle console --network telsius
-
Get an instance of the E-Money Token with its current address:
emoney = await EmoneyToken.at(ADDRESS_EM_TOKEN)
-
Deploy the demo smart contract with the current address of the E-money Token
holdNotary = await HoldNotary.new(emoney.address)
-
Create a hold with an expiration time of 10 minutes and set the smart contract as notary:
emoney.hold(UNIQUE_HOLD_ID, TO_ADDRESS, holdNotary.address, AMOUNT_OF_HOLD, 600)
-
One of the following two transactions can now be made:
a. Call the demo smart contract to release the hold and do not do any transfer:
holdNotary.releaseHold(UNIQUE_HOLD_ID)
b. Call the demo smart contract to execute the hold and transfer the specified amount:
holdNotary.executeHold(UNIQUE_HOLD_ID, AMOUNT_TO_TRANSFER)