Creator Access
Description
By default, only the app owner has the privilege to create contracts within the app, providing strict control over who can interact with the application. However, in certain use cases like marketplaces, it might be desirable to permit any or specific accounts to create contracts within the app.
This can be achieved with ease using the useOpenFormat() hook.
Example
import { useOpenFormat } from "@openformat/react";
import { ethers } from "ethers";
// Get SDK instance
const { sdk } = useOpenFormat();
const ZERO_ADDRESS = ethers.constants.AddressZero;
// This approves ACC_1 and ACC_2 to create contracts within your application.
await sdk.App.setCreatorAccess({
accounts: [ACC_1, ACC_2],
approvals: [true, true],
});
// This approves anyone to create contracts within your application.
await sdk.App.setCreatorAccess({
accounts: [ZERO_ADDRESS],
approvals: [true],
});
// This prevent anyone from creating contracts within your application.
// The owner of the app can also create contract
await sdk.App.setCreatorAccess({
accounts: [ZERO_ADDRESS],
approvals: [false],
});