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:
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
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] 1 => EthLogEntry [source=0x09cabec1ead1c0ba254b09efb3ee13841712be14] (
[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] 1 => TokenPurchase [source=0x09cabec1ead1c0ba254b09efb3ee13841712be14] (
[info] buyer (of type address): 0x465e79b940bc2157e4259ff6b2d92f454497f1e4,
[info] eth_sold (of type uint256): 12406838703909954,
[info] tokens_bought (of type uint256): 2000000000000000000
[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..
[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
Obviously it'd be better not to have to drop into a Scala REPL to do this, though.