Skip to main content

Overview​

The quickstart example uses a script to run our generic domain locally, letting you submit user-level transactions and test out domain functionality right away.

The example is written in TypeScript, but domains can be built in any language.

Running the example​

See the delta-quickstart repository for setup and usage instructions.

The example will guide you through:

  • Installing and running the generic domain with Docker
  • Generating test keys for users and token mints
  • Submitting user-level transactions to mint and transfer tokens
  • Viewing vault contents on the domain

API Reference​

For detailed information on generic domain endpoints and message formats, see the Generic Domain API documentation.

Execution​

The example lets you mint a new fungible token and then transfer some of that newly minted token between vaults using a debit. Both transactions were submitted to the domain which applied them to its local state view. In a real setup, the domain would settle these state changes to the base layer in an additional step.

Local laws​

The example includes a local law implementation that demonstrates domain-specific validation rules.

struct Amounts { min: u64, max: u64 }

impl LocalLaws for MaxAmountLaw {
...
fn validate(
transactions: &[...],
...,
input: &Amounts,
) -> Result<(), LocalLawsError> {
...
}
}

The local law is proven, that is, executed on each batch of transactions before they are settled. The spending limits are provided as input. For each transaction, the law ensures that all DebitAllowance amounts for Fungible tokens fall within the spending range given by input.

if let VerifiableType::DebitAllowance(debit) = ... {
for (token, amount) in &debit... {
if let AllowanceAmount::Fungible(amount) = amount
&& (*amount > input.max || *amount < input.min)
{
return Err(...)
}
}
}

The batch of transactions can only be settled if the law returns Ok(()).