3

Firstly, i love sbt-ethereum. It is zippy and an absolute pleasure. Having completed the contract-interaction portion of the tutorial, I wanted to test out a live contract.

I would like to interact with the uniswap.io ETH-DAI-exchange contract directly from sbt-ethereum to obtain 2 DAI.

  1. I found the dai-token address by scrolling on etherscan
  2. Then used the Uniswap docs to get the uniswap-factory contract address
  3. Called ethTransactionView uniswap-factory getExchange dai-token
  4. This returned the uniswap-dai-exchange address (0x09cabec1ead1c0ba254b09efb3ee13841712be14)
  5. I verified that the Contract ABI on etherscan matched the github version
  6. Then I tried to obtain 2 DAI with a timer of 5 minutes. Varying combinations of input parameters (See A to E), including some with the [ETH to pay, optional] field, failed with the same error.
  7. I checked the dai contract, which seems to be 18 decimals, so I changed the DAI input to 2e18. I tried the optional payment in ether and in finney denominations. I also had a go with the ethToTokenSwapInput, specifying the amount of ETH rather than DAI, same outcome.

[error] com.mchange.sc.v2.jsonrpc.package$JsonrpcException: gas required exceeds allowance or always failing transaction [code=-32000]: No further information

I'm sure it's something simple I'm doing. The sending wallet is funded with >5 DAI worth of ETH.

Any ideas?

Note: I wasn't able to create the new sbt-ethereum tag as intended as reputation <150.


A: ethTransactionInvoke uniswap-dai-exchange ethToTokenSwapOutput 2 300

B: ethTransactionInvoke uniswap-dai-exchange ethToTokenSwapOutput 2 300 15 finney

C: ethTransactionInvoke uniswap-dai-exchange ethToTokenSwapOutput 2000000000000000000 300

D: ethTransactionInvoke uniswap-dai-exchange ethToTokenSwapOutput 2000000000000000000 300 15 finney

E: ethTransactionInvoke uniswap-dai-exchange ethToTokenSwapOutput 2000000000000000000 300 0.015 ether

  • The deadline parameter has to be a unix timestamp. – Ismael May 5 at 20:52
2

First, thanks a ton for trying out sbt-ethereum (and for liking it!).

I was able I think to make the transaction you want to do work. There are two issues:

  1. As @Ismael says, the deadline should be a unix timestamp. (Given the prevalence of these, I should probably add a utility for easily computing them in sbt-ethereum.)

  2. The function you are calling is marked @payable, and does indeed require that you pay the amount of ether you are willing to make available for the swap. It occurs to me that the sbt-ethereum tutorial fails to much emphasize this, but when calling payable functions, after you supply the function arguments you can supply the amount you wish to pay as a number and unit. (Update: I see that you already did notice and try this! So it was mostly just the deadline.)

Another issue is that DAI decimals are 18, so we want 2 plus a lotta zeroes if we just want 2 DAI tokens. (The uint parser in sbt-ethereum doesn't support scientific notation, another thing to remedy!)

So, when all is said and done we have...

> ethTransactionInvoke unverified-uniswap-dai-exchange ethToTokenSwapOutput 2000000000000000000 1557109479 0.015 ether
[info] Unlocking address '0x465e79b940bc2157e4259ff6b2d92f454497f1e4' (on chain with ID 1, aliases ['default-sender','testing0'])
Enter passphrase or hex private key for address '0x465e79b940bc2157e4259ff6b2d92f454497f1e4': *******************
[info] V3 wallet(s) found for '0x465e79b940bc2157e4259ff6b2d92f454497f1e4' (aliases ['default-sender','testing0'])

==> T R A N S A C T I O N   S U B M I S S I O N   R E Q U E S T
==>
==> The transaction would be a message with...
==>   To:    0x09cabec1ead1c0ba254b09efb3ee13841712be14 (with aliases ['unverified-uniswap-dai-exchange'] on chain with ID 1)
==>   From:  0x465e79b940bc2157e4259ff6b2d92f454497f1e4 (with aliases ['default-sender','testing0'] on chain with ID 1)
==>   Data:  0x6b1d4db70000000000000000000000000000000000000000000000001bc16d674ec80000000000000000000000000000000000000000000000000000000000005ccf9ae7
==>   Value: 0.015 Ether
==>
==> The transaction is signed with Chain ID 1 (which correctly matches the current session's 'ethNodeChainId').
==>
==> According to the ABI currently associated with the 'to' address, this message would amount to the following method call...
==>   Function called: ethToTokenSwapOutput(uint256,uint256)
==>     Arg 1 [name=tokens_bought, type=uint256]: 2000000000000000000
==>     Arg 2 [name=deadline, type=uint256]: 1557109479
==>
==> The nonce of the transaction would be 407.
==>
==> $$$ The transaction you have requested could use up to 66235 units of gas.
==> $$$ You would pay 3 gwei for each unit of gas, for a maximum cost of 0.000198705 ether.
==> $$$ This is worth 0.031652712975 USD (according to Coinbase at 7:20 PM).
==> $$$ You would also send 0.015 ether (2.389425 USD), for a maximum total cost of 0.015198705 ether (2.421077712975 USD).

Would you like to submit this transaction? [y/n] y
A transaction with hash '0x0509bafc336c760f21e6c7a1c491d7ba86a6c17c18ec46eec8d87d4995afd8e6' will be submitted. Please wait.
[info] Called function 'ethToTokenSwapOutput', with args '2000000000000000000, 1557109479', sending 15000000000000000 wei to address '0x09cabec1ead1c0ba254b09efb3ee13841712be14' in transaction '0x0509bafc336c760f21e6c7a1c491d7ba86a6c17c18ec46eec8d87d4995afd8e6'.
[info] Waiting for the transaction to be mined (will wait up to 5 minutes).
[info] Transaction Receipt:
[info]        Transaction Hash:    0x0509bafc336c760f21e6c7a1c491d7ba86a6c17c18ec46eec8d87d4995afd8e6
[info]        Transaction Index:   122
[info]        Transaction Status:  SUCCEEDED
[info]        Block Hash:          0x3257d8fd31b49c2c7d55d72c0fddd01f02b92a3326529ed903fdd0e6cb520f9d
[info]        Block Number:        7704627
[info]        From:                0x465e79b940bc2157e4259ff6b2d92f454497f1e4
[info]        To:                  0x09cabec1ead1c0ba254b09efb3ee13841712be14
[info]        Cumulative Gas Used: 6482478
[info]        Gas Used:            54719
[info]        Contract Address:    None
[info]        Logs:                0 => EthLogEntry [source=0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359] (
[info]                                    topics=[
[info]                                      0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef,
[info]                                      0x00000000000000000000000009cabec1ead1c0ba254b09efb3ee13841712be14,
[info]                                      0x000000000000000000000000465e79b940bc2157e4259ff6b2d92f454497f1e4
[info]                                    ],
[info]                                    data=0000000000000000000000000000000000000000000000001bc16d674ec80000
[info]                                  ),
[info]                             1 => EthLogEntry [source=0x09cabec1ead1c0ba254b09efb3ee13841712be14] (
[info]                                    topics=[
[info]                                      0xcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f,
[info]                                      0x000000000000000000000000465e79b940bc2157e4259ff6b2d92f454497f1e4,
[info]                                      0x000000000000000000000000000000000000000000000000002c13f43dbb6c42,
[info]                                      0x0000000000000000000000000000000000000000000000001bc16d674ec80000
[info]                                    ],
[info]                                    data=
[info]                                  )
[info]        Events:              0 => Transfer [source=0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359] (
[info]                                    _from (of type address): 0x09cabec1ead1c0ba254b09efb3ee13841712be14,
[info]                                    _to (of type address): 0x465e79b940bc2157e4259ff6b2d92f454497f1e4,
[info]                                    _value (of type uint256): 2000000000000000000
[info]                                  ),
[info]                             1 => TokenPurchase [source=0x09cabec1ead1c0ba254b09efb3ee13841712be14] (
[info]                                    buyer (of type address): 0x465e79b940bc2157e4259ff6b2d92f454497f1e4,
[info]                                    eth_sold (of type uint256): 12406838703909954,
[info]                                    tokens_bought (of type uint256): 2000000000000000000
[info]                                  )
[success] Total time: 37 s, completed May 5, 2019 7:20:27 PM

sbt:ethdocstore> ethTransactionView 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359 balanceOf testing0
[info] The function 'balanceOf' yields 1 result.
[info]  + Result 1 of type 'uint256', named 'balance', is 2000000000000000002
[success] Total time: 1 s, completed May 5, 2019 7:26:36 PM

The extra 2 atoms at the end of the account balance are due to my originally trying without all those extra zeroes.

You can see if you review the successful transaction, for my 2 DAI I sent out 0.015 ether, but (in an "internal transaction") got 0.002593161296090046 ether back as change.

Thanks again for giving sbt-ethereum a shot. I hope this helps!

p.s. If you want to compute the UNIX timestamp for a 300 second (5 minute) deadline in sbt-ethereum as it is, you can do..

> consoleQuick
[info] Starting scala interpreter...
Welcome to Scala 2.12.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_172).
Type in expressions for evaluation. Or try :help.

scala> (System.currentTimeMillis / 1000) + 300
res0: Long = 1557110378

scala> 

Obviously it'd be better not to have to drop into a Scala REPL to do this, though.

  • Thanks Ismael you were spot on. My deadline was indeed set to a few mins after New Year's 1970. – zederkredez May 6 at 8:25
  • I really do like the tool, and think others will too! It's responsive and customisable a way that no chrome extension has ever been. – zederkredez May 6 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.