Create deployment scripts
Overview
This tutorial explains how to implement the main deployment script and the script for creating Orders.
Directory
Store your scripts in the /script
directory.
1. Implement the main deployment script
The main deployment script handles the following tasks:
- Deploys
OrderFactory
- Deploys
Registry
- Configures the environment
To implement this script, use the following code:
Full code
You can find the full code on GitHub: /script/Deploy.s.sol
/script/Deploy.s.sol
contract Deploy is Script {
function run() external {
vm.startBroadcast(broadcaster);
// An optional registry reuse
Registry registry = registryAddress != address(0)
? Registry(registryAddress)
: new Registry();
new OrderFactory(
address(registry),
scheduler,
factoryOwner
);
vm.stopBroadcast();
}
}
2. Implement the script for creating Orders
This script for creating Orders handles the following tasks:
- Deploys
BasicOrder
throughOrderFactory
- Sets up mock precompiles
- Configures parameters
To implement this script, use the following code:
Full code
You can find the full code on GitHub: /script/CreateOrder.s.sol
/script/CreateOrder.s.sol
contract CreateOrder is Script {
function run(
uint256 thresholdPrice,
Types.PriceCondition priceCondition,
// ... other parameters
) external {
// NEW: Setup mock services
MockSlinkyPrecompile mSlinkyPrecompile = new MockSlinkyPrecompile();
MockWardenPrecompile wPrecompile = new MockWardenPrecompile();
// Create an Order through the OrderFactory contract
FACTORY.createOrder(orderData, maxKeychainFees, OrderType.Basic);
}
}
Next steps
After implementing the deployment scripts, you can finally start implementing Orders. You can choose one of the two Order types: