Atomic Swaps between the Trustlines Blockhain and Ethereum Main Chain
Atomic Swaps between the Trustlines Blockchain and Ethereum Main Chain
Smart Contracts are inherited from the project https://github.com/kabl/ether-cross-chain-swap
Lets say Alice wants to convert Ether to NEM:XEM and Bob NEM:XEM to Ether.
Hint: The wording in this Ethereum smart contract is a bit different as in the NEM documentation. In my opinion NEM naming is confusing. Especial in NEM secret
represents a hash
and is not the real secret.
Steps:
secret
and the hash
of it.secretLock(uint256 _lockTimeSec, bytes32 _hash, address _recipient)
and adds the agreed amount of Ether.hash
to Bob.SecretLockTransaction.create(Deadline.create(), new Mosaic(new MosaicId('nem:xem'), exchangeValue), lockTime, HashType.SHA256, secret, Alice.address, NetworkType.MIJIN);
.SecretProofTransaction.create( Deadline.create(), HashType.SHA256, hash, proof, NetworkType.MAIN_NET);
.proof
the real secret.secretProof(bytes32 _hash, bytes _proof)
. So Bob will receive the Ether.Web3 version 1.x is installed with NPM. Also Truffle comes with Web3 0.2x. The API of these Web3 are not always compatible.