This is an example implementation of a contract which consumes merkle oracle data.
- The oracle box is validated by checking that the singleton asset is present in the box
- The merkle trie is built by extracting the merkle root from the oracle box's datum
- The keyHash, raw value, and membership proof are extracted from the redeemer which is done by the transaction builder
- the contract hashes the raw value then checks that it is present in the merkle trie by using the keyHash and membership proof
After these checks, any business logic can be done as the data in the redeemer is now validated.
In this example, the business logic is to check that the value is greater than a threshold. If it is, the transaction builder can withdraw assets from this (self) utxo.
aiken buildaiken.toml
[config.default]
network_id = 41Or, alternatively, write conditional environment modules under env.
You can write tests in any module using the test keyword. For example:
use config
test foo() {
config.network_id + 1 == 42
}To run all tests, simply do:
aiken checkTo run only tests matching the string foo, do:
aiken check -m fooIf you're writing a library, you might want to generate an HTML documentation for it.
Use:
aiken docsFind more on the Aiken's user manual.