You can run a script using its JSON-ABI and the path to its binary file. You can run the scripts with arguments. For this, you have to use the abigen!
macro seen previously .
The method for passing transaction parameters is the same as with contracts . As a reminder, the workflow would look like this:
Script calls provide the same logging functions, decode_logs()
and decode_logs_with_type<T>()
, as contract calls. As a reminder, the workflow looks like this:
Scripts use the same interfaces for setting external contracts as contract methods .
Below is an example that uses set_contracts(&[&contract_instance, ...])
.
And this is an example that uses set_contract_ids(&[&contract_id, ...])
.
Same as contracts, you can define configurable
constants in scripts
which can be changed during the script execution. Here is an example how the constants are defined.
Each configurable constant will get a dedicated with
method in the SDK. For example, the constant STR_4
will get the with_STR_4
method which accepts the same type defined in sway. Below is an example where we chain several with
methods and execute the script with the new constants.
Was this page helpful?