def send_one_tx(proxy, sender, receiver_address): plain = PlainTransaction() plain.nonce = sender.nonce plain.value = "20000000000000000" # 0.02 ERD plain.sender = sender.address.bech32() plain.receiver = receiver_address plain.gasPrice = 200000000000 plain.gasLimit = 50000 plain.data = "" payload = TransactionPayloadToSign(plain) signature = signing.sign_transaction(payload, sender.pem_file) prepared = PreparedTransaction(plain, signature) prepared.send(proxy) global counter counter += 1 print(f"Sent transaction #{counter}, with nonce = {plain.nonce}.")
def prepare_execute_transaction(self, caller, function, arguments, gas_price, gas_limit, value): arguments = arguments or [] gas_price = int(gas_price or config.DEFAULT_GAS_PRICE) gas_limit = int(gas_limit) value = str(value or "0") plain = PlainTransaction() plain.nonce = caller.nonce plain.value = value plain.sender = caller.address.bech32() plain.receiver = self.address.bech32() plain.gasPrice = gas_price plain.gasLimit = gas_limit plain.data = self.prepare_execute_transaction_data(function, arguments) payload = TransactionPayloadToSign(plain) signature = signing.sign_transaction(payload, caller.pem_file) prepared = PreparedTransaction(plain, signature) return prepared
def prepare_deploy_transaction(self, owner, arguments, gas_price, gas_limit, value): arguments = arguments or [] gas_price = int(gas_price or config.DEFAULT_GAS_PRICE) gas_limit = int(gas_limit or config.DEFAULT_GAS_LIMIT) value = str(value or "0") plain = PlainTransaction() plain.nonce = owner.nonce plain.value = value plain.sender = owner.address.bech32() plain.receiver = Address.zero().bech32() plain.gasPrice = gas_price plain.gasLimit = gas_limit plain.data = self.prepare_deploy_transaction_data(arguments) payload = TransactionPayloadToSign(plain) signature = signing.sign_transaction(payload, owner.pem_file) prepared = PreparedTransaction(plain, signature) return prepared
def send_prepared_transaction(args): proxy = ElrondProxy(args.proxy) prepared = PreparedTransaction.from_file(args.tx) tx_hash = prepared.send(proxy) print(tx_hash) return tx_hash