stx_callContract
You can use the stx_callContract
method to request the signature of any contract call transaction from the user's wallet. The method lets you specify the contract to call, the function to execute on the contract and the arguments to pass to the function.
contract
a string representing the contract's Crockford base-32 encoded Stacks address, and the contract name, separated by a .
Example: ST000000000000000000002AMW42H.pox-3
functionName
a string representing the name of the contract function to call
an array of strings representing the arguments to pass to the function called. The arguments are expected as hex-encoded strings of Clarity values.
To convert Clarity values to their hex representation, you can use the cvToString
helper from the @stacks/transactions
package.
functionArgs
an array of strings representing the arguments to pass to the function called. The arguments are expected as hex-encoded strings of Clarity values.
To convert Clarity values to their hex representation, you can use the cvToString
helper from the @stacks/transactions
package.
postConditions
an array of strings representing the post conditions to be applied on the transaction. post conditions are expected as hex-encoded strings
To convert post conditions values to their hex representation, you can use the postConditionToHex
helper from the @stacks/transactions
package.
postConditionMode
a string representing the post condition mode to evaluate post-conditions:
allow
-> in "allow" mode, other asset transfers not covered by the post-conditions are permitteddeny
-> in "deny" mode, no other asset transfers are permitted besides those named in the post-conditions.
The user will see a Stacks contract call transaction signing request prompt in the wallet.
The transaction will be signed and broadcasted upon user approval.
The stx_callContract
method returns a Promise that resolves to the CallContractResult
object:
txid
a hex-encoded string representing the ID of the Stacks contract call transaction signed
transaction
a hex-encoded string representing the Stacks contract call transaction signed
Last updated