Ionio is a smart contract language that allows you to write complex taproot contracts using simple data structures and APIs.
Marina fully supports Ionio and allows you to derive taproot addresses embedding Ionio contract.
First of all, you need to create a Ionio account. This is a special type of account expecting an Artifact as input to derive a new address.
Once you created your Ionio account, you should be able to select it using
Ionio artifact describes the contract of the script.
vault-calculator/calculator.json is an example of an Ionio artifact. The contract is expecting two inputs:
sumwhich is a number letting to "lock" my coins using a simple math problem.
pubkeywhich is the public key of the signer.
To spend a coin locking by that script I need to provide:
bwhich are the two numbers that sum up to
sigwhich is a schnoor signature belonging to
Marina is able to detect the artifact inputs and inject public keys and signatures automatically. To do this, the "injected" argument must be named like the account name. Fortunately,
@ionio-lang/ionio provides us some helpers:
templateString is an helper function using to rename
marina.getNextChangeAddress injects artifact constructor arguments automatically if and only if the argument name is the same as the account name (and the argument type is XOnlyPublicKey).
Get the coins owned by the Ionio account:
You can try and test the full example here: https://github.com/louisinger/vault-calculator.