Skip to content

ClipFinance/spherex-helper-scripts

 
 

Repository files navigation

spherex-helper-scripts

This repo provides scripts to help you configure and set up the protection of you'r protocol with spherex.

This assumes your smart contracts are already integrated with spherex.

Run in local fork

The current config is forking linea chain (modify as you like in the hardhat.config.js): in one terminal run

npx hardhat node

and in a second terminal run:

npx hardhat run <script> --network localhost --no-compile

The scripts

configureProtectedContracts.js

Configure the operator, engine and protected sigs for each contract in the contracts' data file. In order to run the script, change the four settings at the top of the scripts:

const SPHEREX_OPERATOR_ADDRESS = "0x0000000000000000000000000000000000001337";
const SPHEREX_ENGINE_ADDRESS = "0x0000000000000000000000000000000000001337";
const CONTRACTS_DATA_PATH = "";
const LOCAL_FORK = true;

The contracts_data file should be provided by the spherex team. This script should be run by the spherex admin of the protected contracts (assuming it is the same for all the contracts)

deployAndConfigureEngine.js

Deploy an engine, sets the allowed senders and allowed patterns (does not turn on protection!). In order to run set the three settings at the top of the script:

const ALLOWED_SENDER_PATH = "";
const ALLOWED_PATTERNS_PATH = "";
const LOCAL_FORK = true;

The allowed senders and patterns should be provided by the spherex team.

configureEngine.js

Sets the allowed senders and allowed patterns for an already deployed engine(does not turn on protection!). In order to run set the three settings at the top of the script:

const ALLOWED_SENDER_PATH = "";
const ALLOWED_PATTERNS_PATH = "";
const ENGINE_ADDRESS = "";
const LOCAL_FORK = true;

The allowed senders and patterns should be provided by the spherex team.

Run in a real Chain

In order to run the scripts against a real network you need to configure the hardhat.config.js with the chain's details (see https://hardhat.org/tutorial/deploying-to-a-live-network) and create .env file with your PRIVATE_KEY (see .env.example) Run in a terminal:

npx hardhat run <script> --network <name of the chain in the hardhat config> --no-compile

In both scripts there a global const LOCAL_FORK, don't forget to set it to false!

This script should be run by the spherex admin of the spherex engine

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%