-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-safe.ts
46 lines (34 loc) · 1.13 KB
/
create-safe.ts
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
42
43
44
45
46
import { ethers } from "ethers";
// import { GelatoRelayPack } from "gelato-relay-kit";
import Safe, {
EthersAdapter,
SafeAccountConfig,
SafeFactory,
} from "gelato-raas-protocol-kit";
import * as dotenv from "dotenv";
dotenv.config({ path: ".env" });
let RPC_URL = "https://rpc.op-testnet.gelato.digital";
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const signer = new ethers.Wallet(process.env.PK!, provider);
async function createSafe() {
console.log('Network: ',await provider.getNetwork());
const ethAdapter = new EthersAdapter({
ethers,
signerOrProvider: signer,
});
try {
// try catch to check id
const safeFactory = await SafeFactory.create({ ethAdapter: ethAdapter });
const safeAccountConfig: SafeAccountConfig = {
owners: [await signer.getAddress()],
threshold: 1,
// ... (Optional params)
};
const safeSdkOwner1 = await safeFactory.deploySafe({ safeAccountConfig });
let safeAddress = await safeSdkOwner1.getAddress();
console.log("Safe created with address: ", safeAddress);
} catch (error) {
console.log(error);
}
}
createSafe();