1

I want to call a payable method using the polkadot API.

if the method would not be payable it would look like this:

const { gasRequired, storageDeposit, result, output } = await contract.query
            .method(
                fromAccount,
                {
                    gasLimit,
                    storageDepositLimit
                },
                toAccount,
                input,
                input2
            )

But how could I transfer a certain amount of native chain tokens when calling this method?

1 Answer 1

3

You need to add { value: valueToBeSent } as the last argument in the method

.method( arg1, arg2, { value: valueToBeSent })

This is how it works for tx call:

await contract.connect(owner).tx.createCollection(collectionMetadata, collectionMax, collectionSymbol, { value: reserveValue });

Check also if your query call method is payable. Most likely there is no charge for query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.