Stacks Blockchain (beta) Actions
sign_transaction
The stacks::sign_transaction
action signs an encoded transaction payload with the supplied signer data.
Inputs
- Name
description
- Type
- optional
- Description
Description of the transaction
- Name
transaction_payload_bytes
- Type
- required
- Description
The transaction payload bytes, encoded as a clarity buffer.
- Name
network_id
- Type
- optional
- Description
The network id, which is used to set the transaction version. Can be
"mainnet"
,"testnet"
and"devnet"
.
- Name
signer
- Type
- required
- Description
A reference to a signer construct, which will be used to sign the transaction payload.
- Name
nonce
- Type
- optional
- Description
The account nonce of the signer. This value will be retrieved from the network if omitted.
- Name
fee
- Type
- required
- Description
The transaction fee. This value will automatically be estimated if omitted.
- Name
fee_strategy
- Type
- optional
- Description
The strategy to use for automatically estimating fee ('low', 'medium', 'high'). Default to 'medium'.
Outputs
When the sign_transaction
action is successfully executed, the following outputs are attached to the action
- Name
signed_transaction_bytes
- Description
The signed transaction bytes.
- Name
network_id
- Description
Network id of the signed transaction.
Example using sign_transaction
action "my_ref" "stacks::sign_transaction" {
transaction_payload_bytes = stacks::cv_buff("0x021A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0E707974682D6F7261636C652D76311D7665726966792D616E642D7570646174652D70726963652D66656564730000000202000000030102030C0000000315707974682D6465636F6465722D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE14707974682D706E61752D6465636F6465722D763115707974682D73746F726167652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0D707974682D73746F72652D763116776F726D686F6C652D636F72652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE10776F726D686F6C652D636F72652D7631")
nonce = 1
fee = 1200
network_id = "testnet"
}
output "signed_bytes" {
value = action.my_ref.signed_transaction_bytes
}
// > signed_bytes: 0x8080000000040063A5EDA39412C016478AE5A8C300843879F78245000000000000000100000000000004B0000182C1712C31B7F683F6C56EEE8920892F735FC0118C98FD10C1FDAA85ABEC2808063773E5F61229D76B29784B8BBBBAAEA72EEA701C92A4FE15EF3B9E32A373D8020100000000021A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0E707974682D6F7261636C652D76311D7665726966792D616E642D7570646174652D70726963652D66656564730000000202000000030102030C0000000315707974682D6465636F6465722D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE14707974682D706E61752D6465636F6465722D763115707974682D73746F726167652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0D707974682D73746F72652D763116776F726D686F6C652D636F72652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE10776F726D686F6C652D636F72652D7631
deploy_contract
The deploy_contract
action encodes a contract deployment transaction, signs the transaction using a signer, and broadcasts the signed transaction to the network.
Inputs
- Name
description
- Type
- optional
- Description
Description of the deployment
- Name
contract
- Type
- optional
- Description
Contract informations.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
- Name
rpc_api_url
- Type
- optional
- Description
The URL to use when making API requests.
- Name
rpc_api_auth_token
- Type
- optional
- Description
The HTTP authentication token to include in the headers when making API requests.
- Name
signer
- Type
- required
- Description
A reference to a signer construct, which will be used to sign the transaction payload.
- Name
confirmations
- Type
- optional
- Description
Once the transaction is included on a block, the number of blocks to await before the transaction is considered successful and Runbook execution continues.
- Name
nonce
- Type
- optional
- Description
The account nonce of the signer. This value will be retrieved from the network if omitted.
- Name
fee
- Type
- optional
- Description
The transaction fee. This value will automatically be estimated if omitted.
- Name
post_conditions
- Type
- optional
- Description
The post conditions to include to the transaction.
- Name
post_condition_mode
- Type
- optional
- Description
The post condition mode ('allow', 'deny'). In Allow mode other asset transfers not covered by the post-conditions are permitted. In Deny mode no other asset transfers are permitted besides those named in the post-conditions.
- Name
transforms
- Type
- optional
- Description
An array of transform operations to perform on the contract source, before being its signature.
- Name
dependency_contract_ids
- Type
- optional
- Description
Contracts that are depending on this contract at their deployment.
- Name
lazy_dependency_contract_ids
- Type
- optional
- Description
Contracts that are depending on this contract after their deployment.
- Name
fee_strategy
- Type
- optional
- Description
The strategy to use for automatically estimating fee ('low', 'medium', 'high'). Default to 'medium'.
- Name
contract_instance_name
- Type
- optional
- Description
The name to use for deploying the contract. Will automatically update contract dependencies.
Outputs
When the deploy_contract
action is successfully executed, the following outputs are attached to the action
- Name
signed_transaction_bytes
- Description
The signed transaction bytes.
- Name
tx_id
- Description
The transaction id.
- Name
contract_id
- Description
The contract id.
- Name
result
- Description
The transaction result.
Example using deploy_contract
action "counter_deployment" "stacks::deploy_contract" {
description = "Deploy counter contract."
source_code = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.pyth-oracle-v1"
contract_name = "verify-and-update-price-feeds"
signer = signer.alice
}
output "contract_tx_id" {
value = action.counter_deployment.tx_id
}
// > contract_tx_id: 0x1020321039120390239103193012909424854753848509019302931023849320
deploy_requirement
The deploy_requirement
action retrieves a deployed contract along with its dependencies, signs the transactions using a signer, and broadcasts the signed transactions to the network.
Inputs
- Name
description
- Type
- optional
- Description
Description of the deployment
- Name
contract_id
- Type
- required
- Description
The contract id deployed on Mainnet that needs to mirrored.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
- Name
rpc_api_url_source
- Type
- optional
- Description
The URL to use when making API requests.
- Name
rpc_api_url
- Type
- optional
- Description
The URL to use when making API requests.
- Name
signer
- Type
- required
- Description
A reference to a signer construct, which will be used to sign the transaction payload.
- Name
confirmations
- Type
- optional
- Description
Once the transaction is included on a block, the number of blocks to await before the transaction is considered successful and Runbook execution continues.
- Name
nonce
- Type
- optional
- Description
The account nonce of the signer. This value will be retrieved from the network if omitted.
- Name
fee
- Type
- optional
- Description
The transaction fee. This value will automatically be estimated if omitted.
- Name
post_conditions
- Type
- optional
- Description
The post conditions to include to the transaction.
- Name
transforms
- Type
- optional
- Description
An array of transform operations to perform on the contract source, before being its signature.
- Name
dependency_contract_ids
- Type
- optional
- Description
Contracts that are depending on this contract at their deployment.
- Name
lazy_dependency_contract_ids
- Type
- optional
- Description
Contracts that are depending on this contract after their deployment.
Outputs
When the deploy_requirement
action is successfully executed, the following outputs are attached to the action
- Name
signed_transaction_bytes
- Description
The signed transaction bytes.
- Name
tx_id
- Description
The transaction id.
- Name
result
- Description
The transaction result.
Example using deploy_requirement
action "counter_deployment" "stacks::deploy_requirement" {
description = "Deploy counter contract."
source_code = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.pyth-oracle-v1"
contract_name = "verify-and-update-price-feeds"
signer = signer.alice
}
output "contract_tx_id" {
value = action.counter_deployment.tx_id
}
// > contract_tx_id: 0x1020321039120390239103193012909424854753848509019302931023849320
call_contract
The call_contract
action encodes a valid contract call payload and serializes it as a hex string.
Inputs
- Name
contract_id
- Type
- required
- Description
The address and identifier of the contract to invoke.
- Name
function_name
- Type
- required
- Description
The contract method to invoke.
- Name
function_args
- Type
- optional
- Description
The function arguments for the contract call.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
Outputs
When the call_contract
action is successfully executed, the following outputs are attached to the action
- Name
bytes
- Description
The encoded contract call bytes.
- Name
network_id
- Description
The network id of the encoded transaction.
Example using call_contract
action "my_ref" "stacks::call_contract" {
description = "Encodes the contract call transaction."
contract_id = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.pyth-oracle-v1"
function_name = "verify-and-update-price-feeds"
function_args = [
stacks::cv_buff(output.bitcoin_price_feed),
stacks::cv_tuple({
"pyth-storage-contract": stacks::cv_principal("${env.pyth_deployer}.pyth-store-v1"),
"pyth-decoder-contract": stacks::cv_principal("${env.pyth_deployer}.pyth-pnau-decoder-v1"),
"wormhole-core-contract": stacks::cv_principal("${env.pyth_deployer}.wormhole-core-v1")
})
]
}
output "bytes" {
value = action.my_ref.bytes
}
output "network_id" {
value = action.my_ref.network_id
}
// > bytes: 0x021A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0E707974682D6F7261636C652D76311D7665726966792D616E642D7570646174652D70726963652D66656564730000000202000000030102030C0000000315707974682D6465636F6465722D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE14707974682D706E61752D6465636F6465722D763115707974682D73746F726167652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0D707974682D73746F72652D763116776F726D686F6C652D636F72652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE10776F726D686F6C652D636F72652D7631
// > network_id: testnet
broadcast_transaction
The broadcast_transaction
action sends a signed transaction payload to the specified network.
Inputs
- Name
signed_transaction_bytes
- Type
- required
- Description
The signed transaction bytes that will be broadcasted to the network.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
- Name
rpc_api_url
- Type
- optional
- Description
The URL to use when making API requests.
- Name
rpc_api_auth_token
- Type
- optional
- Description
The HTTP authentication token to include in the headers when making API requests.
- Name
confirmations
- Type
- optional
- Description
Once the transaction is included on a block, the number of blocks to await before the transaction is considered successful and Runbook execution continues.
Outputs
When the broadcast_transaction
action is successfully executed, the following outputs are attached to the action
- Name
tx_id
- Description
The transaction id.
- Name
value
- Description
The transaction id.
- Name
result
- Description
The transaction result.
- Name
decoded_result
- Description
The transaction decoded result.
Example using broadcast_transaction
action "my_ref" "stacks::broadcast_transaction" {
description = "Broadcasts the signed transaction bytes"
signed_transaction_bytes = "0x8080000000040063A5EDA39412C016478AE5A8C300843879F78245000000000000000100000000000004B0000182C1712C31B7F683F6C56EEE8920892F735FC0118C98FD10C1FDAA85ABEC2808063773E5F61229D76B29784B8BBBBAAEA72EEA701C92A4FE15EF3B9E32A373D8020100000000021A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0E707974682D6F7261636C652D76311D7665726966792D616E642D7570646174652D70726963652D66656564730000000202000000030102030C0000000315707974682D6465636F6465722D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE14707974682D706E61752D6465636F6465722D763115707974682D73746F726167652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE0D707974682D73746F72652D763116776F726D686F6C652D636F72652D636F6E7472616374061A6D78DE7B0625DFBFC16C3A8A5735F6DC3DC3F2CE10776F726D686F6C652D636F72652D7631"
}
output "tx_id" {
value = action.my_ref.tx_id
}
output "result" {
value = action.my_ref.result
}
// > tx_id: 0x...
// > result: success
call_readonly_fn
The call_readonly_fn
action queries a public readonly function.
Inputs
- Name
contract_id
- Type
- required
- Description
The address and identifier of the contract to invoke.
- Name
function_name
- Type
- required
- Description
The contract method to invoke.
- Name
function_args
- Type
- optional
- Description
The function arguments for the contract call.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
- Name
rpc_api_url
- Type
- optional
- Description
The URL to use when making API requests.
- Name
rpc_api_auth_token
- Type
- optional
- Description
The HTTP authentication token to include in the headers when making API requests.
- Name
sender
- Type
- optional
- Description
The simulated tx-sender to use.
- Name
block_height
- Type
- optional
- Description
Coming soon.
Outputs
When the call_readonly_fn
action is successfully executed, the following outputs are attached to the action
- Name
value
- Description
The result of the function execution.
Example using call_readonly_fn
call_contract
The call_contract
action encodes a contract call transaction, signs the transaction using an in-browser signer, and broadcasts the signed transaction to the network.
Inputs
- Name
description
- Type
- optional
- Description
Description of the transaction
- Name
contract_id
- Type
- required
- Description
The address and identifier of the contract to invoke.
- Name
function_name
- Type
- required
- Description
The contract method to invoke.
- Name
function_args
- Type
- optional
- Description
The function arguments for the contract call.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
- Name
rpc_api_url
- Type
- optional
- Description
The URL to use when making API requests.
- Name
rpc_api_auth_token
- Type
- optional
- Description
The HTTP authentication token to include in the headers when making API requests.
- Name
signer
- Type
- required
- Description
A reference to a signer construct, which will be used to sign the transaction payload.
- Name
confirmations
- Type
- optional
- Description
Once the transaction is included on a block, the number of blocks to await before the transaction is considered successful and Runbook execution continues.
- Name
nonce
- Type
- optional
- Description
The account nonce of the signer. This value will be retrieved from the network if omitted.
- Name
fee
- Type
- optional
- Description
The transaction fee. This value will automatically be estimated if omitted.
- Name
fee_strategy
- Type
- optional
- Description
The strategy to use for automatically estimating fee ('low', 'medium', 'high'). Default to 'medium'.
- Name
post_conditions
- Type
- optional
- Description
The post conditions to include to the transaction.
- Name
post_condition_mode
- Type
- optional
- Description
The post condition mode ('allow', 'deny'). In Allow mode other asset transfers not covered by the post-conditions are permitted. In Deny mode no other asset transfers are permitted besides those named in the post-conditions.
Outputs
When the call_contract
action is successfully executed, the following outputs are attached to the action
- Name
signed_transaction_bytes
- Description
The signed transaction bytes.
- Name
tx_id
- Description
The transaction id.
- Name
value
- Description
The transaction id.
- Name
result
- Description
The transaction result.
Example using call_contract
action "my_ref" "stacks::call_contract" {
description = "Encodes the contract call, sign, and broadcasts the set-token function."
contract_id = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.pyth-oracle-v1"
function_name = "verify-and-update-price-feeds"
function_args = [
stacks::cv_buff(output.bitcoin_price_feed),
stacks::cv_tuple({
"pyth-storage-contract": stacks::cv_principal("${env.pyth_deployer}.pyth-store-v1"),
"pyth-decoder-contract": stacks::cv_principal("${env.pyth_deployer}.pyth-pnau-decoder-v1"),
"wormhole-core-contract": stacks::cv_principal("${env.pyth_deployer}.wormhole-core-v1")
})
]
signer = signer.alice
}
output "tx_id" {
value = action.my_ref.tx_id
}
output "result" {
value = action.my_ref.result
}
// > tx_id: 0x...
// > result: success
send_stx
The send_stx
action encodes a STX transfer transaction, signs the transaction using a signer, and broadcasts the signed transaction to the network.
Inputs
- Name
amount
- Type
- required
- Description
The amount of STX to send.
- Name
recipient
- Type
- required
- Description
The recipient of the transfer.
- Name
network_id
- Type
- optional
- Description
The network id used to validate the transaction version.
- Name
rpc_api_url
- Type
- optional
- Description
The URL to use when making API requests.
- Name
rpc_api_auth_token
- Type
- optional
- Description
The HTTP authentication token to include in the headers when making API requests.
- Name
signer
- Type
- required
- Description
A reference to a signer construct, which will be used to sign the transaction payload.
- Name
confirmations
- Type
- optional
- Description
Once the transaction is included on a block, the number of blocks to await before the transaction is considered successful and Runbook execution continues.
- Name
nonce
- Type
- optional
- Description
The account nonce of the signer. This value will be retrieved from the network if omitted.
- Name
fee
- Type
- optional
- Description
The transaction fee. This value will automatically be estimated if omitted.
Outputs
When the send_stx
action is successfully executed, the following outputs are attached to the action
- Name
signed_transaction_bytes
- Description
The signed transaction bytes.
- Name
tx_id
- Description
The transaction id.
- Name
result
- Description
The transaction result.
Example using send_stx
action "stx_transfer" "stacks::send_stx" {
description = "Send µSTX to Bob."
recipient = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM"
amount = 1000000
memo = "0x10394390"
signer = signer.alice
}
output "transfer_tx_id" {
value = action.stx_transfer.tx_id
}
// > transfer_tx_id: 0x1020321039120390239103193012909424854753848509019302931023849320