Under Construction The V2 Protocol, SDK, and these docs are under active development. You can find the latest testnet deployments here

In prerelease Currently the SDK and protocol only support Sepolia. Public API’s are stable, but could still change before our initial release. If you experience any bugs, please open a Github issue

A budget has two types of roles that can be granted: ADMIN and MANAGER. These roles can be accessed through the Roles enum:

import { Roles } from "@boostxyz/sdk"
// Roles.MANAGER
// Roles.ADMIN
  • The MANAGER role allows an address to manage funds within the budget and deploy boosts using available funds.
  • The ADMIN role allows an address to grant and revoke roles on the budget as well as manage available funds.

Accounts authorized with the MANAGER role are allowed to disburse available funds from the budget, so make sure you trust the address before granting permissions.

API

grantRoles

Grants access control roles to an address.

await budget.grantRoles(account.address, Roles.ADMIN);

You can grant both ADMIN and MANAGER roles at once:

await budget.grantRoles(account.address, Roles.ADMIN | Roles.MANAGER);

Parameters

address
string
required

The address to grant the roles to.

role
bigint
required

The roles to grant, accessed via the Roles enum.

parameters
Omit<wagmi.WriteContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying writeContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

void
Promise<void>

grantManyRoles

Grants access control roles to multiple addresses. The roles array must match the addresses array in length and order.

await budget.grantManyRoles(
  [account1.address, account2.address],
  [Roles.ADMIN, Roles.MANAGER]
);

Parameters

addresses
string[]
required

Array of addresses to grant roles to.

roles
bigint[]
required

Array of roles to grant, accessed via the Roles enum.

parameters
Omit<wagmi.WriteContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying writeContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

void
Promise<void>

revokeRoles

Revokes access control roles from an address.

await budget.revokeRoles(account.address, Roles.ADMIN);

You can revoke both ADMIN and MANAGER roles at once:

await budget.revokeRoles(account.address, Roles.ADMIN | Roles.MANAGER);

Parameters

address
string
required

The address to revoke roles from.

role
bigint
required

The roles to revoke, accessed via the Roles enum.

parameters
Omit<wagmi.WriteContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying writeContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

void
Promise<void>

revokeManyRoles

Revokes access control roles from multiple addresses. The roles array must match the addresses array in length and order.

await budget.revokeManyRoles(
  [account1.address, account2.address],
  [Roles.ADMIN, Roles.MANAGER]
);

Parameters

addresses
string[]
required

Array of addresses to revoke roles from.

roles
bigint[]
required

Array of roles to revoke, accessed via the Roles enum.

parameters
Omit<wagmi.WriteContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying writeContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

void
Promise<void>

setAuthorized

Grants or revokes the MANAGER role for multiple addresses. The authorized values array must match the addresses array in length and order.

await budget.setAuthorized([account1.address, account2.address], [true, false]);

Parameters

addresses
string[]
required

Array of addresses to set authorization for.

allowed
boolean[]
required

Array of boolean values where true grants and false revokes the MANAGER role.

parameters
Omit<wagmi.WriteContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying writeContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

void
Promise<void>

isAuthorized

Checks if an address is authorized to manage the budget. Returns true if the address is authorized, otherwise false.

await budget.isAuthorized(account.address);

Parameters

account
string
required

The address to check authorization for.

parameters
Omit<wagmi.ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying readContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

boolean
Promise<boolean>

Returns true if the address is authorized, otherwise false.

hasAllRoles

Checks if an address has all the roles specified. Returns true if the address has all the roles, otherwise false.

// Check if the address has the ADMIN role
await budget.hasAllRoles(account.address, Roles.ADMIN);

// Check if the address has both the ADMIN and MANAGER roles
await budget.hasAllRoles(account.address, Roles.ADMIN | Roles.MANAGER);

Parameters

account
string
required

The address to check roles for.

roles
bigint
required

The roles to check for, accessed via the Roles enum.

parameters
Omit<wagmi.ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying readContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

boolean
Promise<boolean>

Returns true if the address has all the specified roles, otherwise false.

hasAnyRole

Checks if an address has at least one of the roles specified. Returns true if the address has at least one of the roles, otherwise false.

// Check if the address has either the ADMIN or MANAGER roles
await budget.hasAnyRole(account.address, Roles.ADMIN | Roles.MANAGER);

Parameters

account
string
required

The address to check roles for.

roles
bigint
required

The roles to check for, accessed via the Roles enum.

parameters
Omit<wagmi.ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying readContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

boolean
Promise<boolean>

Returns true if the address has at least one of the specified roles, otherwise false.

rolesOf

Returns the an array of roles for a given address. Returns an empty array if the address has no roles. 1n = Roles.MANAGER, 2n = Roles.ADMIN

await budget.rolesOf(account.address);
// [ 1n, 2n ]

Parameters

account
string
required

The address to check roles for.

parameters
Omit<wagmi.ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying readContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

bigint[]
Promise<bigint[]>

Returns an array of roles for the address.

owner

Returns the budget owner’s address.

await budget.owner();
// "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"

Parameters

parameters
Omit<wagmi.ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>

Optional parameters to pass to the underlying readContract method. Checkout wagmi’s documentation for more information. address, args, functionName, abi are handled for you under the hood.

Returns

string
Promise<string>

The budget owners address.