forked from cerc-io/stack-orchestrator
3dc9cd584a
* Add a mobymask-v3 stack * Fix Nitro deployment script and add watcher container * Setup Nitro config * Run build after setting Nitro addresses * Setup consensus config * Add a container for web-app * Use node 18 for the web-app * Persist Nitro node data to a volume * Add clean up steps * Update query rates
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import 'dotenv/config';
|
|
import fs from 'fs';
|
|
import { providers, Wallet } from 'ethers';
|
|
import { deployContracts } from '@cerc-io/nitro-util';
|
|
|
|
async function main () {
|
|
const rpcURL = process.env.RPC_URL;
|
|
const addressesFilePath = process.env.NITRO_ADDRESSES_FILE_PATH;
|
|
const deployerKey = process.env.PRIVATE_KEY;
|
|
|
|
if (!rpcURL) {
|
|
console.log('RPC_URL not set, skipping deployment');
|
|
return;
|
|
}
|
|
|
|
if (!addressesFilePath) {
|
|
console.log('NITRO_ADDRESSES_FILE_PATH not set, skipping deployment');
|
|
return;
|
|
}
|
|
|
|
if (!deployerKey) {
|
|
console.log('PRIVATE_KEY not set, skipping deployment');
|
|
return;
|
|
}
|
|
|
|
const provider = new providers.JsonRpcProvider(process.env.RPC_URL);
|
|
const signer = new Wallet(deployerKey, provider);
|
|
|
|
const [
|
|
nitroAdjudicatorAddress,
|
|
virtualPaymentAppAddress,
|
|
consensusAppAddress
|
|
] = await deployContracts(signer as any);
|
|
|
|
const output = {
|
|
nitroAdjudicatorAddress,
|
|
virtualPaymentAppAddress,
|
|
consensusAppAddress
|
|
};
|
|
|
|
fs.writeFileSync(addressesFilePath, JSON.stringify(output, null, 2));
|
|
console.log('Nitro contracts deployed, addresses written to', addressesFilePath);
|
|
console.log('Result:', JSON.stringify(output, null, 2));
|
|
}
|
|
|
|
main()
|
|
.catch((err) => {
|
|
console.log(err);
|
|
});
|