gary02 / contracts

Matters Solidity contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solidity Smart Contracts of Matters Lab

Contracts

Name Network Address
Logbook Polygon Mumbai 0x203197e074b7a2f4ff6890815e4657a9c47c68b1

In the "Contract" tab of Polygonscan/Etherscan, you can see the contract code and ABI.

ABI

See Docs for Contract ABI.

Usages

import { ethers } from "ethers";

/**
 * Instantiate contract
 */
const address = "0x203197e074b7a2f4ff6890815e4657a9c47c68b1";
const abi = '[{"inputs":[{"internalType":"string","name":"name_","type":"string"}...]';
const alchemyAPIKey = "...";
const provider = new ethers.providers.AlchemyProvider("maticmum", alchemyAPIKey);
const contract = new ethers.Contract(address, abi, provider);

/**
 * Interact with contract
 */
// mint a logbook
const publicSalePrice = await contract.publicSalePrice();
const tokenId = await contract.publicSaleMint({ value: publicSalePrice });

// set title, description & fork price in one transaction
const title = "Ut cupidatat";
const description = "Ut cupidatat amet ea et veniam amet aute aute eu.";
const forkPrice = ethers.utils.parseEther("0.1"); // 0.1 Ether to Wei
const iface = new ethers.utils.Interface(abi);
const calldata = [
  // title
  iface.encodeFunctionData("setTitle", [tokenId, title]),
  // description
  iface.encodeFunctionData("setDescription", [tokenId, title]),
  // fork price
  iface.encodeFunctionData("setForkPrice", [tokenId, forkPrice]),
];
await contract.multicall(calldata);

// donate
const donationAmount = ethers.utils.parseEther("0.02");
await contract.donate(tokenId, { value: donationAmount });

Ethers.js also supports Human-Readable ABI, it's recommended to use, for smaller client bundle size.

To query the contract data, please checkout thematters/subgraphs.

Development

Install Forge

Environment

cp .env.local.example .env.local

Build

make build

Testing

make test

Deployment

Deploy on Local Node:

# Run local node
npm run ganache

# Preprare environment
cp .env.local.example .env.local
cp .env.polygon-mainnet.example .env.polygon-mainnet
cp .env.polygon-mumbai.example .env.polygon-mumbai

# Deploy Logbook contract (defaults to local node)
make deploy-logbook

# Deploy currency first, then add the contract address to THESPACE_CURRENCY_ADDRESS env variable
make deploy-the-space-currency
# Deploy the space contract
make deploy-the-space

# Deploy the snapper contract
# Preprare SNAPPER_THESPACE_CREATION_BLOCKNUM and SNAPPER_THESPACE_INITIAL_SNAPSHOT_CID (a png file IPFS CID) env variable first, then:
make deploy-snapper

Deploy on testnet or mainnet:

# Deploy The Space contract
make deploy-the-space

# Deploy to Poygon Mainnet
make deploy-the-space NETWORK=polygon-mainnet

# Deploy to Polygon Mumbai
make deploy-the-space NETWORK=polygon-mumbai

Verify Contract

Automatically

# Verify on Polygon Mumbai
make verify-the-space NETWORK=polygon-mumbai

# Verify on Poygon Mainnet
make verify-the-space NETWORK=polygon-mainnet

Manually

# 1. Concat all file into one
forge flatten src/Logbook/Logbook.sol

# 2. On (Polygonscan)[https://mumbai.polygonscan.com/verifycontract], Select "Solidity (Single File)" and upload

About

Matters Solidity contracts

License:Apache License 2.0


Languages

Language:Solidity 96.8%Language:Shell 1.4%Language:Makefile 1.1%Language:JavaScript 0.7%