Ionio Account
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.
#
Create an Ionio accountFirst 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.
#
Use your Ionio accountOnce you created your Ionio account, you should be able to select it using useAccount
.
#
Generate addresses from Ionio artifactIonio artifact describes the contract of the script.
vault-calculator/calculator.json is an example of an Ionio artifact. The contract is expecting two inputs:
sum
which is a number letting to "lock" my coins using a simple math problem.pubkey
which is the public key of the signer.
To spend a coin locking by that script I need to provide:
a
andb
which are the two numbers that sum up tosum
sig
which is a schnoor signature belonging topubkey
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:
tip
templateString
is an helper function using to rename artifact
arguments.
tip
marina.getNextAddress
and 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).
#
Spend coins owned by Ionio accountGet the coins owned by the Ionio account:
tip
More infos about how to spend an Ionio contract using the Javascript SDK: http://ionio-lang.org/docs/SDK/transactions
You can try and test the full example here: https://github.com/louisinger/vault-calculator.