From 8e0ef86733e962c4b145ac80f483b656b427e550 Mon Sep 17 00:00:00 2001 From: yukonet <58343698+yukonet@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:03:51 +0000 Subject: [PATCH] fix multipayout nonce --- app/token.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/token.py b/app/token.py index 116ce2f..c53a18b 100644 --- a/app/token.py +++ b/app/token.py @@ -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']), @@ -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")), @@ -184,6 +185,8 @@ def make_multipayout_eth(self, payout_list, fee,): "txids": [txid.hex()], }) + nonce = nonce + 1 + return payout_results @@ -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}) @@ -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) @@ -540,6 +544,7 @@ def make_token_multipayout(self, payout_list, fee,): "status": "success", "txids": [txid.hex()], }) + nonce = nonce + 1 return payout_results