Giter VIP home page Giter VIP logo

contracts-1's Introduction

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

# 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

contracts-1's People

Contributors

robertu7 avatar guoliu avatar gary02 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.