forked from Protox-Labs/protox-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ts
More file actions
40 lines (30 loc) · 1.35 KB
/
Copy pathdeploy.ts
File metadata and controls
40 lines (30 loc) · 1.35 KB
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
import { Address, Keypair, Networks, TransactionBuilder, SorobanRpc, xdr } from '@stellar/stellar-sdk';
import * as dotenv from 'dotenv';
import { readFileSync } from 'fs';
dotenv.config();
/**
* Deploys the vault-contract to the Stellar network.
*/
async function deployContract() {
const rpc = new SorobanRpc.Server(process.env.RPC_URL || 'https://soroban-testnet.stellar.org');
const secret = process.env.CONTRACT_ADMIN_SECRET;
if (!secret) {
throw new Error("CONTRACT_ADMIN_SECRET is not set in environment");
}
const keypair = Keypair.fromSecret(secret);
const account = await rpc.getAccount(keypair.publicKey());
// Load the WASM file
const wasmPath = './contracts/vault-contract/target/wasm32-unknown-unknown/release/protox_vault.wasm';
const wasmBuffer = readFileSync(wasmPath);
console.log('Deploying contract...');
// TODO: Implement the full Soroban deployment flow:
// 1. Upload WASM
// 2. Instantiate contract
// 3. Log the contract ID
// This is a placeholder for the actual deployment logic
console.log('Contract deployed successfully!');
console.log('Contract ID: CD... (Example)');
}
deployContract().catch(console.error);
// TODO: Add support for different network configurations (Futurenet, Mainnet)
// TODO: Implement robust error handling and retry logic for RPC calls