10.2 创建订单脚本 (Create order script)

https://github.com/compolabs/spark/tree/master/services/predicate-orders-builder/create_order_script

Create order script performs two actions: it sends funds to the predicate, thereby initiating the creation of an order and makes a log with the parameters of the order, which will help in indexing the order.

创建订单脚本执行两个动作:它向谓词发送资金,从而启动订单的创建,并将订单的参数做成日志,这将有助于为订单建立索引。

script;
use std::token::transfer_to_address;
use std::logging::log;

struct CreateOrderParams {
    id: str[30],
    predicate_address: Address,
    amount0: u64,
    asset0: ContractId,
    amount1: u64,
    asset1: ContractId,
    owner: Address,
}
fn main(params: CreateOrderParams) {
    log(params);
    transfer_to_address(params.amount0, params.asset0, params.predicate_address);
}

Last updated