thundercore / auction-template

2 stars 1 forks source link

Fails to bid on Testnet #6

Open bafu opened 3 years ago

bafu commented 3 years ago

Stes to Reproduce

truffle(thunder-testnet)> f.createAuction('1618922820', '1', '1', accounts[0])
{
    ...
    blockNumber: 46249946,
    event: 'AUCTION_CREATED',
    ...
}

truffle(thunder-testnet)> f.getPastEvents("AUCTION_CREATED", {fromBlock: 46249946})
[
    ...
    auction: '0x0e532A69bEFe23cAb46a395c6D774D3A449A52EA',
    owner: '0x4718e08377292B4b243a6E891D14e10967E1652F',
]

truffle(thunder-testnet)> a = await Auction.at("0x0e532A69bEFe23cAb46a395c6D774D3A449A52EA")

truffle(thunder-testnet)> a.bid(0)

Error Logs

truffle(thunder-testnet)> a.bid(0)
Uncaught: 
StatusError: Transaction: 0x1370f778abee564ddba3c48cb4b9f1371f47155234bbdc09ea8ea5a35f17a791 exited w
ith an error (status 0).                  
    at evalmachine.<anonymous>:0:3              at sigintHandlersWrap (vm.js:273:12)                                                             
    at Script.runInContext (vm.js:140:14)                                                            
    at runScript (/home/bafu/codes/auction-template/node_modules/truffle/build/webpack:/packages/core
/lib/console.js:270:1)    at Console.interpret (/home/bafu/codes/auction-template/node_modules/truffle/build/webpack:/packa
ges/core/lib/console.js:285:1)
    at bound (domain.js:413:15)
    at REPLServer.runBound [as eval] (domain.js:424:12)
    at REPLServer.onLine (repl.js:817:10)
    at REPLServer.emit (events.js:315:20)
    at REPLServer.EventEmitter.emit (domain.js:467:12)
    at REPLServer.Interface._onLine (readline.js:337:10)
    at REPLServer.Interface._line (readline.js:666:8)
    at REPLServer.Interface._ttyWrite (readline.js:1010:14)
    at REPLServer.self._ttyWrite (repl.js:907:9)
    at ReadStream.onkeypress (readline.js:213:10)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:467:12)
    at emitKeys (internal/readline/utils.js:345:14)
    at emitKeys.next (<anonymous>)
    at ReadStream.onData (readline.js:1144:36) {
  tx: '0x1370f778abee564ddba3c48cb4b9f1371f47155234bbdc09ea8ea5a35f17a791',
  receipt: {
    blockHash: '0x1466fbfffea91f0c7089974a1255a33f082c780b288bb9d9d1669c0c2ebe75c2',
    blockNumber: 46250139,
    contractAddress: null,
    cumulativeGasUsed: 296800,
    from: '0x4718e08377292b4b243a6e891d14e10967e1652f',
    gasUsed: 296800,
    logs: [],
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000',
    status: false,
    to: '0x0e532a69befe23cab46a395c6d774d3a449a52ea',
    transactionHash: '0x1370f778abee564ddba3c48cb4b9f1371f47155234bbdc09ea8ea5a35f17a791',
    transactionIndex: 0,
    rawLogs: []
  },
  reason: undefined,
  hijackedStack: 'StatusError: Transaction: 0x1370f778abee564ddba3c48cb4b9f1371f47155234bbdc09ea8ea5a
35f17a791 exited with an error (status 0). \n' +
    '     Please check that the transaction:\n' +
    '     - satisfies all conditions set by Solidity `require` statements.\n' +
    '     - does not trigger a Solidity `revert` statement.\n' +
    '\n' +
    '    at Object.receipt (/home/bafu/codes/auction-template/node_modules/truffle/build/webpack:/pac
kages/contract/lib/handlers.js:128:1)\n' +
    '    at runMicrotasks (<anonymous>)\n' +
    '    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
    '    at Function.start (/home/bafu/codes/auction-template/node_modules/truffle/build/webpack:/pac
kages/contract/lib/override.js:49:1)'
}
bafu commented 3 years ago

Can make accounts[0] to bid successfully:

truffle(thunder-testnet)> tteth = await ERC20Token.at("0x6757D10620c46219aF1E2f0E23144682d1aDBCC2")
truffle(thunder-testnet)> tteth.approve("0x0e532A69bEFe23cAb46a395c6D774D3A449A52EA", 50, {from: accounts[0]})
truffle(thunder-testnet)> a.bid(0)

but accounts[1] fails to run approve

truffle(thunder-testnet)> await tteth.approve("0x0e532A69bEFe23cAb46a395c6D774D3A449A52EA", 40, {from: accounts[1]})
Uncaught { code: -32000, message: 'nonce too low' }
o-p commented 3 years ago
  1. yes, have to approve contract to transfer account's token before bidding
  2. it seems the transaction nonce of account has been used before, not the contract issue.