-
Notifications
You must be signed in to change notification settings - Fork 35
Ion Stage 1 Smart Contracts
Ion Lock walkthrough Smart Contracts used.
The contracts below are the two main contracts being interacted with.
images/state_machine_ion_stage_1.png
Implements IonLinkInterface
.
Maintains latest merkle root to be verified against a proof given to the withdraw function in ERC223.
It is made of two functions: Update( uint256 _new_block_root )
which updates the latest merkle root, and Verify( uint256 block_id, uint256 leaf_hash, uint256[] proof )
which verifies is a proof and leaf given correspond to a merkle tree root submitted at the block id given.
It receives new roots from our Lithium service but any intermediary can submit these roots. The roots submitted must be generated for leaves that have the structure that is defined in IonLock
.
Implements ERC223ReceivingContract
.
Allows withdraws through Withdraw( uint256 _value, bytes32 _ref, uint256 _block_id, uint256[] _proof )
. When a withdraw is made the the proof given is verified against IonLink.
The proof is an array of hashes that is a path to the leaf being verified. The leaf hash must be in the format H(address_of_withdraw_beneficiary, token_contract_address, ionlock_contract_address, amount_of_tokens, H(payment_reference_of_opposite_deposit))
where H()
is the keccak256
hashing function.
The contracts below are either libraries or interfaces used by the core contracts or are additional helper contracts required for the stack to function and are replaceable by custom contracts.
ECVerify.sol library
A safer ecrecovery(bytes32 hash, bytes sig)
implementation.
ERC223.sol interface
Describes the ERC223 Token standard.
ERC223Compatible.sol interface
Describes the ERC223ReceivingContract
interface.
The ERC223ReceivingContract
defines how tokenFallback(address _from, uint _value, bytes _data)
should look in order to implement contracts that are able to receive tokens.
IonCompatible.sol interface
Describes IonLinkInterface
and IonCompatible
.
IonCompatible
describes interface for multiple events to be triggered in order for Lithium (externally) to catch them.
IonLinkInterface
interface (describing the verify function).
Merkle.sol library
Implements Merkle utils for verification of root and proofs validity.
Truffle utility file.
Classic implementation of math utils to avoid overflows and other problems.
Implements ERC223. (ERCC223 Standard)[https://github.com/ethereum/EIPs/issues/223] token implementation similar to the one used on the Asset Token.
Clearmatics :D