aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Bug]AssertionError: {"message":"parse request payload error: Expected input type \"TransactionPayload\", found {\"type\":\"script_function_payload\"

Open twtesmarry opened this issue 3 years ago • 4 comments

🐛 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.

twtesmarry avatar Sep 02 '22 10:09 twtesmarry

Officially changed the playload param script_function_payload to entry_function_payload.I think you can check python sdk code about translate function.

lynn-hector avatar Sep 05 '22 02:09 lynn-hector

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

twtesmarry avatar Sep 05 '22 03:09 twtesmarry

changed the playload param script_function_payload to entry_function_payload

twtesmarry avatar Sep 08 '22 02:09 twtesmarry

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 txn_hash = rest_client.bcs_transfer(alice, bob.address(), 1_000) File "C:\Users\Adm\AppData\Local\Programs\Python\Python310\lib\site-packages\aptos_sdk\client.py", line 268, in bcs_transfer return self.submit_bcs_transaction(signed_transaction) File "C:\Users\Adm\AppData\Local\Programs\Python\Python310\lib\site-packages\aptos_sdk\client.py", line 107, in submit_bcs_transaction assert response.status_code == 202, f"{response.text} - {signed_transaction}" AssertionError: {"message":"Failed to deserialize input into SignedTransaction","error_code":"invalid_input","vm_error_code":null} - Transaction: RawTranasction: sender: 0x9035dcaccecbd15e94ade03d69b458e520f6762e3fa3582d8e09864a34fc3f3b sequence_number: 1 payload: 0x0000000000000000000000000000000000000000000000000000000000000001::coin::transfer::<[0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin]>([b'V8\x8e\xc6\x85\xe5\xdf?\xd5GU\xcbl\xb2\xdf\xbc\x8d\xddt\xa7\x00\xc9hu8#\xa4Y\xf5\xfev\xf2', b'\xe8\x03\x00\x00\x00\x00\x00\x00']) max_gas_amount: 2000 gas_unit_price: 1 expiration_timestamps_secs: 1662603652 chain_id: 25 Authenticator: PublicKey: 0x63a0691c2cd22a076a082fbfa9c951925a13ae10848b203027f3bcb050b33ffb, Signature: 0xd92851b7f9f0ecf02b77bb55b573b4d9b80c380442472e4caa916be1816817155b3d8061d30edab3f80c38cbddbf90cfa6eb13ee2caf51623b6d8a457c540e05

twtesmarry avatar Sep 08 '22 02:09 twtesmarry

What's the version of the SDK you're using?

gregnazario avatar Sep 14 '22 05:09 gregnazario

image 0.2.0

twtesmarry avatar Sep 14 '22 11:09 twtesmarry

can you please use 0.3.0. it should work

jjleng avatar Sep 14 '22 18:09 jjleng

SDK 0.3.0

twtesmarry avatar Sep 21 '22 03:09 twtesmarry

image Does SDK 0.3.0 support Testnet network? If supported, how to modify the parameters of the request?

twtesmarry avatar Sep 21 '22 03:09 twtesmarry

Please review the appropriate guides: https://aptos.dev/guides/getting-started#aptos-developer-resources for example

davidiw avatar Sep 25 '22 19:09 davidiw