ioCash smart contracts


Contents






EMToken - ERC 2020



ioCash team, in collaboration with Adhara, have created the ERC 2020, EM-Token Standard that extends the ERC-20 token standard and adds extra functionalities with the aim to enable the issuance of regulated electronic money on blockchain networks and its practical usage in real financial applications.

These main functionalities are: compliance, holds, clearing, funding requests and payouts orders.

ioCash is already using these concepts in its smart contracts. The next paragraphs will explain how you can use some of these functionalities by interacting with the smart contracts.





Interacting with ioCash smart contract



ioCash smart contracts are built based on the EM-Token standard. All ioCash smart contracts inherit from one master contract that we have called the EM-Token smart contract. Therefore, you can access all the available functionalities (holds, transfers, two step transfers etc.) by making calls against it.

In order to interact with it you can use the following abstract EM-Token contract from our GitHub repository. Our Github also contains a couple of very simple smart contract examples that showcase the interaction with the EM-Token.

You can also check the demo web app that we have created to interact with the EM-Token. You could use it to get familiar with the creation of Dapps using the EM-Token and to build on top of it some extra functionalities with the aim of doing a simple and fast PoC or a demo of your use case.


Current Em-Token smart contract addresses


Alastria Telsius


PRO environment: 0x404c41BAd3cDf3fC0D3793508C8901F933A013f6

PRE environment: 0x1941Ec3d95d98AFA440eCeC1F89E3d3f8ac03AE0



LacChain


PRO environment: 0x4ED243E531F89d1b74b29d38dad1d16f3748F755

PRE environment: 0xF874D63F221a31588B8B49E39bB06faDEc9781DB



ioBuilders network - Hyperledger Besu


PRO environment: 0x1332659eEc06022eb5C9F83Eb5707a1aD8a08451

PRE environment: 0x8774543882Bb710D918696D032f9cA6A4CB1C72E





Features


The EM-Token offers the following features:

Transfers


ioCash is fully compliant with the ERC-20 standard which is used for transfers. The following functions are available:

transfer
Send tokens to another address.

transferFrom
Send tokens on behalf of somebody else.

approve
Allow another address to send on your behalf.

allowance
Tells you how much somebody can send on somebody else's behalf.

balanceOf
Tells you how many tokens an address has.

totalSupply
Tells you total amount of all tokens combined.

decimals
Tells you how many decimals after the coma can be used when transferring tokens.

symbol
Tells you the individual symbol of a token.

name
Tells you the individual name of a token.



For more details please see the ERC-20 standard.


Holds


Holds guarantee a future transfer and make the held tokens unavailable for transfer in the meantime. Holds are similar to escrows because they are firm and lead to final settlement.
A hold specifies a payer, a target, an amount, a notary and an expiration time. When the hold is created, the specified token balance from the payer is put on hold. A held balance cannot be transferred until the hold is either executed or released. The hold can only be executed by the notary, which triggers the transfer of the tokens from the payer to the payee. The execution of a hold can be done with the full amount or a partial one. If only a partial hold is executed the remaining tokens are available again to the payer. If a hold is released, either by the notary or the target no transfer is carried out and the amount is available again for the payer. It is also possible to add an expiration date to holds. If ther hold has not yet been executed or released and the expiration date is achieved, the held quantity is realesed on the sender's account. The expiration of a hold is optional, it can also be perpetual (no expiration).

The following functions are offered:

hold
Creates a new hold.

holdWithExpirationDate
Creates a new hold passing the expiration date in seconds instead of the time until it expires.

holdFrom
Creates a new hold on behalf of another account.

holdFromWithExpirationDate
Creates a new hold on behalf of another account passing the expiration date in seconds instead of the time until it expires.

executeHold
Transfers all or a part of the tokens which were specified when creating the hold. The remaining part of the hold that is not sent is released on the sender's account

executeHoldAndKeepOpen
Transfers a part of the tokens which were specified when creating the hold. The remaining part that is not sent is kept on hold for a future execution or release.

releaseHold
Does not make a transfer and makes the held tokens available again to the payer.

renewHold
Changes the expiration time.

renewHoldWithExpirationDate
Changes the expiration time passing the expiration date in seconds instead of the time until it expires.

retrieveHoldData
Returns the details of a given hold.

balanceOnHold
Tells you how many tokens of an address are held.

netBalanceOf
Tells you how many tokens including the held tokens an address has.

totalSupplyOnHold
Tells you total amount of all held tokens combined.

authorizeHoldOperator
Authorizes an account to create holds on behalf of the sender.

revokeHoldOperator
Revokes the permission to create holds on behalf of the sender.

isHoldOperatorFor
Returns if an account is authorized to create hold on behalf of another account.


The following ERC-20 functions behave differently than the standard if a hold is used:

balanceOf
The held balance of an account is deducted from the ERC-20 balance. In order to get all tokens assigned to an account the function virtualBalanceOf has to be used.

transfer
The implementation of ERC-20 has been changed in order to deduct the held balance from the ERC-20 balance. Any amount that is held can not be transferred.

transferFrom
The standard implementation of ERC-20 has been changed in order to deduct the held balance from the ERC-20 balance. Any amount that is held can not be transferred.


For more details please see our GitHub repository with the interface of the Holdable Token.



Two Step Transfers


The two step transfer (clearing) process turns the promise of a transfer into the actual movement of money from one account to another. It has the same properties as a hold, but the notary and expiration are set automatically by the ioCash platform. The amount which should be transferred is not deducted from the balance of the payer, but neither is it available for another transfer and therefore ensures, that the execution of the transfer will be successful when it is executed. Off-chain checks are executed to decide if the transfer can be executed or not.

The following functions are offered:

orderTransfer
Creates a request for a transfer.

releaseTransfer
Transfers the token which were specified when requesting the transfer.

revokeTransferByExpiration
Revokes the transfer after it has expired.

revokeTransferByNotary
The notary can revoke the hold at any time.

revokeTransferByTarget
The target can revoke the hold at any time.



For more details please see our GitHub repository with the interface of the TwoStep Transferable Token.




Smart contract error codes


For size reasons, we have codified some revert reasons of our smart contracts. Although the movements already have the translation made and the error text is displayed, if you are directly working with our smart contracts you will get the plain error codes. You can use the table below for the needed translation.


Error code Error reason
0x21 Compliance registry cannot be zero address
0x22 Registry cannot be zero address
0x10 Operation only allowed for owner/bank
0x11 Only available for migrator
0x12 Only available for operators
0x16 Only allowed if one step transfers are activated
0x32 Token is already locked
0x1D Action not allowed to any user
0x14 Token is locked
0x15 Token not whitelisted
0x16 Token can not trade partial amounts
0x17 Sender is not allowed to send tokens
0x18 Receiver is not allowed to receive tokens
0x19 Sender is not allowed to mint tokens
0x1A Sender is not allowed to burn tokens
0x1B The sender is unsubscribed
0x1C The receiver is unsubscribed
0x23 The address is not permissioned in the token
0x50 Amount should be greater than zero