Skip to content

Commit

Permalink
fix multipayout nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
yukonet committed Dec 13, 2024
1 parent 972b7fe commit 8e0ef86
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def make_multipayout_eth(self, payout_list, fee,):
if have_crypto < should_pay:
raise Exception(f"Have not enough crypto on fee account, need {should_pay} have {have_crypto}")
else:
nonce = self.provider.eth.get_transaction_count(self.get_fee_deposit_account())
for payout in payout_list:
test_transaction = {"from": self.provider.toChecksumAddress(self.get_fee_deposit_account()),
"to": self.provider.toChecksumAddress(payout['dest']),
Expand All @@ -167,7 +168,7 @@ def make_multipayout_eth(self, payout_list, fee,):
'from': self.provider.toChecksumAddress(self.get_fee_deposit_account()),
'to': self.provider.toChecksumAddress(payout['dest']),
'value': self.provider.toHex(self.provider.toWei(payout['amount'], "ether")),
'nonce': self.provider.eth.get_transaction_count(self.get_fee_deposit_account()),
'nonce': nonce,
'gas': self.provider.toHex(gas_count),
'maxFeePerGas': self.provider.toHex(self.provider.toWei(max_fee_per_gas, 'ether')),
'maxPriorityFeePerGas': self.provider.toHex( self.provider.toWei(fee, "ether")),
Expand All @@ -184,6 +185,8 @@ def make_multipayout_eth(self, payout_list, fee,):
"txids": [txid.hex()],
})

nonce = nonce + 1


return payout_results

Expand Down Expand Up @@ -516,6 +519,7 @@ def make_token_multipayout(self, payout_list, fee,):
if need_crypto_for_multipayout > have_crypto:
raise Exception(f"Have not enough crypto on fee account, need {need_crypto_for_multipayout} have {have_crypto}")
else:
nonce = self.provider.eth.get_transaction_count(payout_account)
for payout in payout_list:

gas = self.contract.functions.transfer(payout['dest'], int((Decimal(payout['amount']) * 10** (self.contract.functions.decimals().call())))).estimateGas({'from': payout_account})
Expand All @@ -529,7 +533,7 @@ def make_token_multipayout(self, payout_list, fee,):
'gas': gas,
'maxFeePerGas': self.provider.toWei(max_fee_per_gas, 'ether'),
'maxPriorityFeePerGas': self.provider.toWei(Decimal(fee), 'ether'),
'nonce': self.provider.eth.get_transaction_count(payout_account),
'nonce': nonce,
'chainId': self.provider.eth.chain_id})
signed_txn = self.provider.eth.account.sign_transaction(unsigned_txn, private_key= self.get_seed_from_address(payout_account))
txid = self.provider.eth.sendRawTransaction(signed_txn.rawTransaction)
Expand All @@ -540,6 +544,7 @@ def make_token_multipayout(self, payout_list, fee,):
"status": "success",
"txids": [txid.hex()],
})
nonce = nonce + 1

return payout_results

Expand Down

0 comments on commit 8e0ef86

Please sign in to comment.