forked from cisc0f/hedera
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeploy.js
25 lines (18 loc) · 873 Bytes
/
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
require('dotenv').config({path: __dirname + '/../../.env'});
const { AccountId, PrivateKey, Client, ContractCreateFlow } = require('@hashgraph/sdk');
const fs = require('fs');
const main = async () => {
const accountId = AccountId.fromString(process.env.ACCOUNT_ID);
const privateKey = PrivateKey.fromString(process.env.PRIVATE_KEY);
const client = Client.forTestnet().setOperator(accountId, privateKey);
const bytecode = fs.readFileSync('contract_create_flow.bin');
// Create contract using ContractCreateFlow
const createContract = new ContractCreateFlow()
.setGas(100000)
.setBytecode(bytecode)
const createTx = await createContract.execute(client);
const createRx = await createTx.getReceipt(client);
const contractId = createRx.contractId;
console.log(`Contract created with ID: ${contractId}`);
}
main();