Bako Safe SDK
Bako Ecosystem (recommended)
Vault

Creating Vault using Payload

import { IPayloadVault, Vault, BakoSafe, Auth } from 'bakosafe'
import { Address } from 'fuels'
 
const auth = await Auth.create(params_auth)
 
// sign auth code using your PK
const sig = await Auth.signerByPk(YOUR_PRIVATE_KEY, auth.code)
await auth.signerByAccount(sig)
 
// find the configurables needed to create a vault
const { abi } = await Vault.BakoSafeGetCurrentVersion()
console.log(JSON.parse(abi).configurables)
 
const params_vault: 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'),
  },
  BakoSafeAuth: auth.BakoSafeAuth,
}
 
const vault = await Vault.create(params_vault)

It is also possible to create a vault using payload with a specific predicate contract version.

import { IPayloadVault, Vault, BakoSafe, Auth } from 'bakosafe'
import { Address } from 'fuels'
 
const auth = await Auth.create(params_auth)
 
// sign auth code using your PK
const sig = await Auth.signerByPk(YOUR_PRIVATE_KEY, auth.code)
await auth.signerByAccount(sig)
 
const safe_code = 'real_code'
const vaultVersion = await Vault.BakoSafeGetPredicateVersionByCode(safe_code)
 
const params_vault: 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'),
  },
  BakoSafeAuth: auth.BakoSafeAuth,
  version: vaultVersion.code,
}
 
const vault = await Vault.create(params_vault)

Creating Vault using ID or Address

import { BakoSafe, Auth } from 'bakosafe'
 
import { Provider } from 'fuels'
 
provider = await Provider.create(BakoSafe.getProviders('CHAIN_URL'))
 
const myAccount: {
  account: YOUR_ACCOUNT
  address: YOUR_ADDRESS
  privateKey: YOUR_PRIVATE_KEY
}
 
const auth = await Auth.create(account, provider.url)
 
const auxVault = await Vault.create({
  ...auth.BakoSafeAuth,
  id: vault.BakoSafeVaultId,
})
 
// using Address
const auxVault = await Vault.create({
  ...auth.BakoSafeAuth,
  predicateAddress: vault.address.toString(),
})