What is Terminus?

Terminus is a smart contract which allows you to manage access control using on-chain tokens.

It allows you to create token pools which represent levels of access to your systems. You can grant or revoke access by minting or burning the corresponding tokens.

Terminus supports decentralized access control, with pool controllers that can be people, bots, or other smart contracts. It also you to delegate administrative authority to other accounts.

Interfaces

Using Terminus from off-chain: the Terminus ABI

Using Terminus from Solidity: ITerminus

Code

https://github.com/bugout-dev/dao

Recipes

Below are recipes to perform common tasks using Terminus, with both web3.js and Solidity code examples.

Create Authorization Pools

web3.js

const Web3 = require("web3");
const web3 = new Web3("https://your_rpc_endpoint");

const TerminusABI = require("./TerminusABI.json");
const TerminusAddress = process.env.TERMINUS_ADDRESS;
const terminusContract = new web3.eth.Contract(TerminusABI, TerminusAddress);

// Load private key from environment variable
const privateKey = process.env.PRIVATE_KEY;
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

const createPool = async (capacity, transferable, burnable, poolURI) => {
  const data = terminusContract.methods.createPoolV2(capacity, transferable, burnable, poolURI).encodeABI();
  const tx = {
    to: TerminusAddress,
    data: data,
    gas: await terminusContract.methods.createPoolV2(capacity, transferable, burnable, poolURI).estimateGas({ from: account.address }),
  };
  const signedTx = await account.signTransaction(tx);
  const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  return receipt;
};

// This creates a pool with a capacity of 100 tokens. Tokens in this pool are
// transferable (the first true) and burnable (the second true). The metadata for
// this pool of tokens is expected to be at <https://example.com/pool_uri>.
createPool(100, true, true, "<https://example.com/pool_uri>").then(receipt => {
  console.log("Pool created:", receipt);
}).catch(err => {
  console.error("Error:", err);
});

Solidity

pragma solidity ^0.8.0;

import "./ITerminus.sol";

contract AuthorizationManager {
    ITerminus public terminus;

    constructor(address _terminusAddress) {
        terminus = ITerminus(_terminusAddress);
    }

    function createAuthorizationPool(uint256 capacity, bool transferable, bool burnable, string memory poolURI) public {
        terminus.createPoolV2(capacity, transferable, burnable, poolURI);
    }
}

Mint Authorization Tokens

web3.js