import { IPayloadVault, Vault, BakoSafe } from 'bakosafe'
import { Address } from 'fuels'
// find the configurables needed to create a vault
const { abi } = await Vault.BakoSafeGetCurrentVersion()
console.log(JSON.parse(abi).configurables)
const params: IPayloadVault = {
name: 'My First Vault',
description: 'This is my first example of a Vault',
// configurable properties are defined according to the ABI configurables of the predicate contract version
configurable: {
SIGNATURES_COUNT: 1,
SIGNERS: [Address.fromRandom().toString(), Address.fromRandom().toString()],
network: BakoSafe.getProviders('CHAIN_URL'),
},
}
const vault = await Vault.create(params)
It is also possible to create a vault with a specific predicate contract version.
import { IPayloadVault, Vault, BakoSafe } from 'bakosafe'
import { Address } from 'fuels'
const safe_code = 'real_code'
const vaultVersion = await Vault.BakoSafeGetVersionByCode(safe_code)
const params: IPayloadVault = {
name: 'My First Vault',
description: 'This is my first example of a Vault',
configurable: {
SIGNATURES_COUNT: 1,
SIGNERS: [Address.fromRandom().toString(), Address.fromRandom().toString()],
network: BakoSafe.getProviders('CHAIN_URL'),
},
version: vaultVersion.code,
}
const vault = await Vault.create(params)