-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
41 lines (35 loc) · 1.18 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require('dotenv').config({ path: '.env.local' });
const fs = require('fs');
const { AeSdk, MemoryAccount, Node } = require('@aeternity/aepp-sdk');
const shutdown = (varName) => {
console.error(`Missing ENV variable: ${varName}`);
process.exit(1);
}
if(!process.env.SECRET_KEY_DEPLOYER) {
shutdown('SECRET_KEY_DEPLOYER');
}
// run 'generateBytecodeAndAci.js' first
const aci = require('../generated_artifacts/aci.json');
const bytecode = fs.readFileSync('../generated_artifacts/bytecode', 'utf8');
const AE_NETWORK = process.env.AE_NETWORK || 'TESTNET'
const SETTINGS = {
TESTNET: {
nodeUrl: 'https://testnet.aeternity.io'
},
MAINNET: {
nodeUrl: 'https://mainnet.aeternity.io'
}
}
const main = async () => {
const node = new Node(SETTINGS[AE_NETWORK].nodeUrl);
const aeSdk = new AeSdk({
nodes: [
{ name: AE_NETWORK, instance: node },
],
accounts: [new MemoryAccount(process.env.SECRET_KEY_DEPLOYER)],
});
const contract = await aeSdk.initializeContract({ aci, bytecode });
await contract.init("Wrapped AENS", "WAENS", 180_000, 100);
console.log(`Deployed at: ${contract.$options.address}`);
}
main();