Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Last active June 21, 2020 03:40
Show Gist options
  • Save ltfschoen/898bc43a103459657e8a04ef6293f695 to your computer and use it in GitHub Desktop.
Save ltfschoen/898bc43a103459657e8a04ef6293f695 to your computer and use it in GitHub Desktop.
lockdrop-setup

Test in Remix

  • Open MetaMask, connect to Ropsten, and import an account with some Testnet ETH to pay for gas costs
  • Go to https://remix.ethereum.org/#appVersion=0.7.7&optimize=false&version=soljson-v0.5.16+commit.9c3226ce.js
  • Open the directory and choose all relevant Lockdrop related smart contracts (the ones in this PR https://github.com/DataHighway-DHX/mining/pull/11/files)
  • Change all the imports so they are importing from the same browser-based directory:
    • i.e. change import "./lib/ERC20.sol"; to import "./ERC20.sol";
  • Go to "Compile" > "Start Compile". Fix any compiler errors
  • Go to "Run"
    • choose Environment "Injected Web3 Ropsten"
    • choose Account ""
    • choose Gas Limit "3000000"
    • choose Value "20" Gwei
    • Choose:
    • Alternatively:
      • Paste the address where the Lockdrop contract was deployed to on Ropsten into "At Address"
        • Click the "At Address" text button
    • In the MetaMask popup, click to "Edit" the "Gas Price", then click "Advanced", and enter Gas Price: 42, and Gas Limit: 3339875
    • In the "Deployed Contracts" section, click to expand "Lockdrop at 0x...."

Convert the DataHighway Address to Hex and then to Bytes

truffle console --network ropsten --verbose-rpc
const res = web3.utils.utf8ToHex("<DATAHIGHWAY_PUBLIC_KEY")

Note: It doesn't appear necessary to then run web3.utils.hexToBytes(res)

  • In Remix, paste that hex value in value for key dataHighwayPublicKey when calling the smart contract. 0x2768fdab1c89b4cfcabd9aff80d87ece0d496a39

  • Transact "signal" function:

    • Paste value: "3","100","0x46765939697a514462737a7a46556b437a65643435547039785062754b4e516e4d563150676b385959444b43573476","0x2768fdab1c89b4cfcabd9aff80d87ece0d496a39"
    • OR "signalFromContract": "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161","1","3","100","0x46765939697a514462737a7a46556b437a65643435547039785062754b4e516e4d563150676b385959444b43573476","0x2768fdab1c89b4cfcabd9aff80d87ece0d496a39"
    • Click "transact" button
    • Choose 30 Gwei and 75000 Gas Limit
    • Successfully works!
  • Call "signalWalletStructs":

    • Paste value: "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161","0x2768fdab1c89b4cfcabd9aff80d87ece0d496a39"
    • Click "call" button
    • Success - it returns (if it failed it'd return 0: address[]:)
      0: uint8: claimStatus 0
      1: uint256: approvedTokenERC20Amount 0
      2: uint8: term 3
      3: uint256: tokenERC20Amount 100
      4: bytes: dataHighwayPublicKey 0x46765939697a514462737a7a46556b437a65643435547039785062754b4e516e4d563150676b385959444b43573476
      5: address: contractAddr 0x0000000000000000000000000000000000000000
      6: uint32: nonce 0
      7: uint256: createdAt 1592554374
      
  • transact "setClaimStatus", to Approve it (i.e. "1")

    • Paste value: "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161","1","0x2768fdab1c89b4cfcabd9aff80d87ece0d496a39","1","100"
    • Click "transact" button
    • SOLVED - it works if replace using StandardToken token = StandardToken ... with ERC20 token = ERC20 ...for some reason.
  • Call "signalWalletStructs" again to check it's Approved with correct amount

    • Paste value: "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161","0x2768fdab1c89b4cfcabd9aff80d87ece0d496a39"
    • Click "call" button
    • Success - it returns (if it failed it'd return 0: address[]:)
      0: uint8: claimStatus 1
      1: uint256: approvedTokenERC20Amount 100
      ...
      
    • IMPORTANT: Ensure that you have deployed the MXCToken to the tokenContractAddress and on the network that you're using (i.e. Ropsten, or Rinkeby). If you try to run the above and enter the wrong ERC20 token (e.g. MXCToken), then the transaction will fail with unknown error
  • Transact "lock" function:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment