Skip to main content

Overview​

The quickstart example uses a script to run a generic domain locally using the delta Gateway, 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 delta Gateway 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 delta gateway endpoints and message formats, see the delta gateway 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 are submitted to the domain which applies 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.

Guardrails​

The example includes a guardrail 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 guardrail condition 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 guardrail 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 guardrail program returns Ok(()).