Spend Context
The SpendContext
is an important utility used by the driver code to simplify coin spends. You can think of it as a wrapper around Allocator with these additional benefits:
- A simpler interface for common operations.
- Automatic caching for puzzle pointers, since the size can be large.
- Simple mechanism for currying a puzzle with its arguments.
- Keeps track of coin spends for you, so that they can be collected at the end in one place.
Setup
It's just as easy to create a SpendContext
as an Allocator
:
use chia_sdk_driver::SpendContext;
let mut ctx = SpendContext::new();
You can also create one from an existing Allocator
, although you shouldn't need to do this that often:
use clvmr::Allocator;
let mut ctx = SpendContext::from(Allocator::new());