Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Created June 21, 2020 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltfschoen/b673a035c0ced7198e209b71ed99f2b7 to your computer and use it in GitHub Desktop.
Save ltfschoen/b673a035c0ced7198e209b71ed99f2b7 to your computer and use it in GitHub Desktop.
debug-weenus
i deployed a duplicate of Weenus from my account 0x1f... to 0x2d2c5fdfcc44fb2c9cdaebc468d6cb23a809d5cd
then (using a separate Remix window since different .sol files use different solc versions)
i compiled and deployed Test.sol passing my Weenus contract address as param `0x2d2c5fdfcc44fb2c9cdaebc468d6cb23a809d5cd`
it was deployed to 0x6ccadfd4e2233656e77b41d6c55bc8deb9753497
then loaded WeenusToken using `AtAddress` 0x2d2c5fdfcc44fb2c9cdaebc468d6cb23a809d5cd
and clicked `approve` using argument "0x6ccadfd4e2233656e77b41d6c55bc8deb9753497, 100", and it's mined successfully
and clicked `balanceOf` using argument of my address "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161" and it showed i had 1000 WEENUS
then loaded Test using `AtAddress` 0x6ccadfd4e2233656e77b41d6c55bc8deb9753497
clicked `depositTokens` using argument `1`
and it transfers 1 WEENUS from my account to the Weenus contract. It works in this tx https://rinkeby.etherscan.io/tx/0x27e5d5cf2d5dea6fda463fd378726dbb51a891ed96d69399569783a72cd87921
then if i click `withdrawTokens` and provide the same amount of `1`, it allows me to withdraw them again
i deployed MXCToken (that imports StandardToken) on Rinkeby here: 0x6d8fc9e069f8fbab67a0a93d9cb19d3d16e21ccc
(the same code that MXC used to deploy it to mainnet)
then i compiled and deployed Test.sol passing my MXCToken contract address as param `0x6d8fc9e069f8fbab67a0a93d9cb19d3d16e21ccc`
it was deployed to 0x39a81aa7f7abdf9938a1da95aaad8a6cbc01946e
then loaded MXCToken using `AtAddress` 0x6d8fc9e069f8fbab67a0a93d9cb19d3d16e21ccc
OPTION 1 - approve my EOA (instead of the Test.sol contract address) to run transfer/transferFrom
and clicked `approve` using argument "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161, 100", and it's mined successfully
https://rinkeby.etherscan.io/tx/0xee57a300750d6c24059d58d147a3abc8588954b9c3e03d971f39712343862148
then loaded Test using `AtAddress` 0x6ccadfd4e2233656e77b41d6c55bc8deb9753497
clicked `depositTokens` using argument `1`
but it failed with error: https://rinkeby.etherscan.io/tx/0xfd2daff0dc52d582a54f2af99821f75df69cc4d899fd7da879fec06f3d90be70
OPTION 2 - approved Test.sol contract address (instead of EOA address) to run transfer/transferFrom
and clicked `approve` using argument "0x6ccadfd4e2233656e77b41d6c55bc8deb9753497, 100", and it's mined successfully
then loaded Test using `AtAddress` 0x6ccadfd4e2233656e77b41d6c55bc8deb9753497
clicked `depositTokens` using argument `1`
but it failed with error: https://rinkeby.etherscan.io/tx/0x406558b1cdf2664ef658146e4a088e4741790d0cee0702a7c341778783ba2aaf
so i modified MXCToken's transferFrom function to be almost the same as the one in Weenus contract
(see this Git commit https://github.com/DataHighway-DHX/mining/commit/7b757732891a7e236f501fbf940c340c8da6c46f)
i deployed the modified MXCToken on Rinkeby here: 0xf9508637cf26ac89b06ae139a2ff1443591d2308
then i compiled and deployed Test.sol passing my MXCToken contract address as param `0xf9508637cf26ac89b06ae139a2ff1443591d2308`
it was deployed to 0x28e7e7dfe171b3e37aa9bac397b3bf4bd0e7a209
then loaded MXCToken using `AtAddress` 0xf9508637cf26ac89b06ae139a2ff1443591d2308
OPTION 1 - approve my EOA (instead of the Test.sol contract address) to run transfer/transferFrom
and clicked `approve` using argument "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161, 100", and it's mined successfully
then loaded Test using `AtAddress` 0x28e7e7dfe171b3e37aa9bac397b3bf4bd0e7a209
clicked `depositTokens` using argument `1`
but it failed with error: https://rinkeby.etherscan.io/tx/0xe962e75ca9e395a6f4de1c574d8967299b44cfccc3fcac9faad88d8300b469ba
OPTION 2 - approved Test.sol contract address (instead of EOA address) to run transfer/transferFrom
and clicked `approve` using argument "0x28e7e7dfe171b3e37aa9bac397b3bf4bd0e7a209, 100", and it's mined successfully
then loaded Test using `AtAddress` 0x28e7e7dfe171b3e37aa9bac397b3bf4bd0e7a209
clicked `depositTokens` using argument `1`
but it failed with error: https://rinkeby.etherscan.io/tx/0xdcce0cbe79b14e88e754a08f928a61ed680e6cc65a7db9835c3cc837467369d3
so that didn't work...
so i made a few more changes to MXCToken's transferFrom and approve functions to be the same as the one in Weenus contract
(see this Git commit with the changes https://github.com/DataHighway-DHX/mining/commit/a02e5176a45176946a0536649295cf6291b49325)
i deployed the modified MXCToken on Rinkeby here: 0xa96a6e35b1362945fe6731e562c975c01252f427
https://rinkeby.etherscan.io/tx/0x4afd73e9a500e7d220255503dd9f75da833d4d4fa787614f5a68e8d5b6acad0e
then i compiled and deployed Test.sol passing my MXCToken contract address as param `0xa96a6e35b1362945fe6731e562c975c01252f427`
it was deployed to 0x9098fd322e7d60f39a2ebc47da012b844f412c25
then loaded MXCToken using `AtAddress` 0xa96a6e35b1362945fe6731e562c975c01252f427
OPTION 1 - approve my EOA (instead of the Test.sol contract address) to run transfer/transferFrom
and clicked `approve` using argument "0x1f7ace08af5c49a5d69fbb98fb9339a729b27161, 100", and it's mined successfully
https://rinkeby.etherscan.io/tx/0x281aa91181512bda6a860f87f7caf11517c3b2f74dd6bff7fa4beb3fc5551fde
then loaded Test.sol using `AtAddress` 0x9098fd322e7d60f39a2ebc47da012b844f412c25
clicked `depositTokens` using argument `1`
but it failed with error: https://rinkeby.etherscan.io/tx/0x77dbe7453b021d614036734849b7faf91f1571f663dd5c23324e4283ec383ac6
OPTION 2 - approved Test.sol contract address (instead of EOA address) to run transfer/transferFrom
and clicked `approve` using argument "0x9098fd322e7d60f39a2ebc47da012b844f412c25, 100", and it's mined successfully
then loaded Test.sol using `AtAddress` 0x9098fd322e7d60f39a2ebc47da012b844f412c25
clicked `depositTokens` using argument `1`
and it compiled successfully: https://rinkeby.etherscan.io/tx/0x77a60adb81f06594efdeb70008c75b77e79f890bc64757e99878621ed9007aff
POTENTIAL SOLUTION FOUND: `uint` works but `uint256` (in MXCToken contract), but why? is it the way i input the value (i.e. 100 instead of "100" in Remix),
and in Lock.sol, do I need to use `uint` instead of `uint256` for `uint256 _tokenERC20Amount` (so it's like `uint tokens` in Weenus contract)?
SOLUTION: we have to `approve` the smart contract address that has the code where we're running `transferFrom` (not the EOA that created that contract)
so i reverted MXCToken's code to original again, and only changed `uint256` to `uint` in the `transferFrom` and `approve` function
i deployed the modified MXCToken on Rinkeby here: 0xf64de39ba73436c0ee6400bdbd9ad00411e9370b
https://rinkeby.etherscan.io/tx/0x5c2934c3ec38ffe9381fb914d4ffbdecc74e1599c929ea5ef775eecc6333806b
then i compiled and deployed Test.sol passing my MXCToken contract address as param `0xf64de39ba73436c0ee6400bdbd9ad00411e9370b`
it was deployed to 0xd7b67d69fe1a9978632a7d7f934330cd9028558f
then loaded MXCToken using `AtAddress` 0xf64de39ba73436c0ee6400bdbd9ad00411e9370b
OPTION 2 - approved Test.sol contract address (instead of EOA address) to run transfer/transferFrom
and clicked `approve` using argument "0xd7b67d69fe1a9978632a7d7f934330cd9028558f", 100, and it's mined successfully
then loaded Test using `AtAddress` 0x28e7e7dfe171b3e37aa9bac397b3bf4bd0e7a209
clicked `depositTokens` using argument `1`
and it compiled successfully: https://rinkeby.etherscan.io/tx/0x95ef3fdcb17c76d49dd47aa64f6efdafaee8d0c0d2a9ba5e4d7be16cf71c3408
SOLUTION: so the only change that was required to the MXCToken contract, was to modify it's `approve` and `transferFrom` functions to use
`uint` instead of `uint256`?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment