0.0.39 • Published 1 year ago

airdao-node-contracts-dev v0.0.39

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Airdao node contracts

Smart contracts used in Airdao.
+Javascript SDK, that can be imported for convenient communication with deployed contracts.

Development

Run npm run test or npm run coverage to test contacts;

// todo add cmd for sourcify

Run make run in amb-node-cluster folder to launch local amb network in your docker;

Deployment

Provide your private key as PRIVATEKEY_OWNER_AMB env var or put it in .env file.

Run npx hardhat run ./scripts/deploy_multisig.ts --network test/amb to deploy masterMultisig contract in testnet network;
Run npx hardhat run ./scripts/deploy_finance.ts --network main/amb to deploy finance contracts (with their multisigs) in mainnet network;
And so on...

SDK

Installing

You must have .npmrc in the same directory as your package.json with following content: @ambrosus:registry=https://npm.pkg.github.com

Now you can do npm install @ambrosus/airdao-node-contracts

Usage

It contains deployed contract addresses for both (testnet and mainnet) networks and convenient methods to use it.
It also contains AmbErrorProvider - use it instead of default provider to get human-readable errors from contracts.

Examples:

import { AmbErrorProviderWeb3, Contracts, ContractNames, Multisig } from "airdao-node-contracts";

const provider = new AmbErrorProviderWeb3(window.ethereum); // for human-readable errors
const signer = provider.getSigner();
const chainId = (await provider.getNetwork()).chainId;

// signer can be undefined, if you dont want to call methods
// chainId must be testnet or mainnet network; Received contract addresses depends on it
const contracts = new Contracts(signer, chainId);
// `contracts` contains all deployed contracts
// you can get contract instance (ethers) via `getContractByName` or `getContractByAddress`,
// but in most cases you doesn't need to use this;
// PLEASE, use `ContractNames` enum for contract names! real value can be changed!

// get all multisig permissions
const { users, groups } = await Multisig.getPermissions(contracts);

// get all transactions
const txs = await Multisig.getTransactionsFromContracts(contracts);

// you can use map like this to display contract names that you want
const contractsNames = {
  [contracts.getContractByName(ContractNames.MasterMultisig).address]: "Permissions",
  [contracts.getContractByName(ContractNames.FinanceRewards).address]: "Finance: Rewards",
};
const nameToDisplay = contractsNames[txs[0].calledContractAddress];

// Create multisig tx, that withdraw 420 amb (wei) from FinanceMaster contract to signer
await Multisig.financeWithdraw(contracts, ContractNames.FinanceMaster, await signer.getAddress(), 420);
0.0.39

1 year ago

0.0.38

1 year ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.34

1 year ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago