aptos-core
aptos-core copied to clipboard
[Bug]AssertionError: {"message":"parse request payload error: Expected input type \"TransactionPayload\", found {\"type\":\"script_function_payload\"
🐛 Bug
AssertionError: {"message":"parse request payload error: Expected input type "TransactionPayload", found {"type":"script_function_payload","function":"0x1::coin::transfer","type_arguments":["0x1::aptos_coin::AptosCoin"],"arguments":["0xb59102d3ae93f30ac7cb17300b60bbad227dd5f55a10d05ab95b6340921c6737","1000"]}. (occurred while parsing "UserTransactionRequestInner") (occurred while parsing "EncodeSubmissionRequest")","error_code":"web_framework_error","vm_error_code":null}
I followed the linked tutorial "https://aptos.dev/guides/creating-a-signed-transaction" and the program ran "transfer-coin.py", but it didn't output as expected
To reproduce
Code snippet to reproduce
from aptos_sdk.account import Account
from aptos_sdk.client import FaucetClient, RestClient
import os
#:!:>section_1
NODE_URL = os.getenv("APTOS_NODE_URL", "https://fullnode.devnet.aptoslabs.com/v1")
FAUCET_URL = os.getenv(
"APTOS_FAUCET_URL", "https://faucet.devnet.aptoslabs.com"
)
if __name__ == "__main__":
#:!:>section_1
rest_client = RestClient(NODE_URL)
faucet_client = FaucetClient(FAUCET_URL, rest_client) # <:!:section_1
#:!:>section_2
alice = Account.generate()
bob = Account.generate() # <:!:section_2
print("\n=== Addresses ===")
print(f"Alice: {alice.address()}")
print(f"Bob: {bob.address()}")
#:!:>section_3
faucet_client.fund_account(alice.address(), 20_000)
faucet_client.fund_account(bob.address(), 0) # <:!:section_3
print("\n=== Initial Balances ===")
#:!:>section_4
print(f"Alice: {rest_client.account_balance(alice.address())}")
print(f"Bob: {rest_client.account_balance(bob.address())}") # <:!:section_4
# Have Alice give Bob 1_000 coins
#:!:>section_5
txn_hash = rest_client.transfer(alice, bob.address(), 1_000) # <:!:section_5
#:!:>section_6
rest_client.wait_for_transaction(txn_hash) # <:!:section_6
print("\n=== Intermediate Balances ===")
print(f"Alice: {rest_client.account_balance(alice.address())}")
print(f"Bob: {rest_client.account_balance(bob.address())}")
# Have Alice give Bob another 1_000 coins using BCS
txn_hash = rest_client.bcs_transfer(alice, bob.address(), 1_000)
rest_client.wait_for_transaction(txn_hash)
print("\n=== Final Balances ===")
print(f"Alice: {rest_client.account_balance(alice.address())}")
print(f"Bob: {rest_client.account_balance(bob.address())}")
rest_client.close()
Stack trace/error message
=== Addresses ===
Alice: 0x013ee9d2ff8c8cc7a0267c116be3d9c1fe5b2508a245c37cb0f67b4ae6b2d92e
Bob: 0xb59102d3ae93f30ac7cb17300b60bbad227dd5f55a10d05ab95b6340921c6737
=== Initial Balances ===
Alice: 20000
Bob: 0
Traceback (most recent call last):
File "C:\Users\Adm\Desktop\gogo\text1.py", line 39, in <module>
txn_hash = rest_client.transfer(alice, bob.address(), 1_000) # <:!:section_5
File "C:\Users\Adm\AppData\Local\Programs\Python\Python310\lib\site-packages\aptos_sdk\client.py", line 247, in transfer
return self.submit_transaction(sender, payload)
File "C:\Users\Adm\AppData\Local\Programs\Python\Python310\lib\site-packages\aptos_sdk\client.py", line 130, in submit_transaction
assert res.status_code == 200, res.text
AssertionError: {"message":"parse request payload error: Expected input type \"TransactionPayload\", found {\"type\":\"script_function_payload\",\"function\":\"0x1::coin::transfer\",\"type_arguments\":[\"0x1::aptos_coin::AptosCoin\"],\"arguments\":[\"0xb59102d3ae93f30ac7cb17300b60bbad227dd5f55a10d05ab95b6340921c6737\",\"1000\"]}. (occurred while parsing \"UserTransactionRequestInner\") (occurred while parsing \"EncodeSubmissionRequest\")","error_code":"web_framework_error","vm_error_code":null}
Expected Behavior
=== Addresses === Alice: 0x0baec07bfc42f8018ea304ddc307a359c1c6ab20fbce598065b6cb19acff7043 Bob: 0xc98ceafadaa32e50d06d181842406dbbf518b6586ab67cfa2b736aaddeb7c74f
=== Initial Balances === Alice: 20000 Bob: 0
=== Intermediate Balances === Alice: 18996 Bob: 1000
=== Final Balances === Alice: 17992 Bob: 2000
System information
Please complete the following information:
- Computer OS:Windows 10
- Python:3.10
Additional context
Add any other context about the problem here.
Officially changed the playload param script_function_payload to entry_function_payload.I think you can check python sdk code about translate function.
thank you for your reply. "python sdk code about translate function", where can I find what you said, can you send me the detailed link or screenshot? Looking forward to your reply, thank you
changed the playload param script_function_payload to entry_function_payload
but
=== Addresses === Alice: 0x9035dcaccecbd15e94ade03d69b458e520f6762e3fa3582d8e09864a34fc3f3b Bob: 0x56388ec685e5df3fd54755cb6cb2dfbc8ddd74a700c968753823a459f5fe76f2
=== Initial Balances === Alice: 20000 Bob: 0
=== Intermediate Balances ===
Alice: 18949
Bob: 1000
Traceback (most recent call last):
File "C:\Users\Adm\Desktop\gogo\text1.py", line 48, in
What's the version of the SDK you're using?
0.2.0
can you please use 0.3.0. it should work
SDK 0.3.0
Does SDK 0.3.0 support Testnet network?
If supported, how to modify the parameters of the request?
Please review the appropriate guides: https://aptos.dev/guides/getting-started#aptos-developer-resources for example