2022-10-24 17:17:08 +00:00
|
|
|
# p2pix-smart-contracts
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
**Repository for P2Pix EVM contracts to be imported by the project.**
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-26 00:36:44 +00:00
|
|
|
## SM Dependency Tree
|
|
|
|
|
|
|
|
```rs
|
|
|
|
./contracts/
|
|
|
|
├── DataTypes.sol
|
|
|
|
├── EventAndErrors.sol
|
|
|
|
├── lib
|
|
|
|
│ ├── auth
|
|
|
|
│ │ └── Owned.sol
|
2022-12-02 18:35:20 +00:00
|
|
|
│ ├── interfaces
|
|
|
|
│ │ └── IReputation.sol
|
2022-11-26 00:36:44 +00:00
|
|
|
│ ├── mock
|
|
|
|
│ │ └── mockToken.sol
|
|
|
|
│ ├── tokens
|
|
|
|
│ │ └── ERC20.sol
|
|
|
|
│ └── utils
|
2022-12-02 18:35:20 +00:00
|
|
|
│ ├── MerkleProofLib.sol
|
2022-11-26 00:36:44 +00:00
|
|
|
│ ├── ReentrancyGuard.sol
|
|
|
|
│ └── SafeTransferLib.sol
|
2022-12-02 18:35:20 +00:00
|
|
|
├── p2pix.sol
|
|
|
|
└── Reputation.sol
|
2022-11-26 00:36:44 +00:00
|
|
|
```
|
2022-12-03 04:17:48 +00:00
|
|
|
|
2022-11-26 00:36:44 +00:00
|
|
|
## Callgraph
|
2022-12-03 04:17:48 +00:00
|
|
|
|
2022-11-26 00:36:44 +00:00
|
|
|
![Callgraph](docs/callgraph.svg)
|
|
|
|
|
2023-01-27 00:40:17 +00:00
|
|
|
## Current Deployment addresses
|
|
|
|
|
|
|
|
### V1
|
2023-02-14 21:40:02 +00:00
|
|
|
|
|
|
|
| Testnet | Token Address | P2pix Address |
|
|
|
|
| ------- | ------------------------------------------ | ------------------------------------------ |
|
|
|
|
| Goerli | 0x294003F602c321627152c6b7DED3EAb5bEa853Ee | 0x5f3EFA9A90532914545CEf527C530658af87e196 |
|
|
|
|
| Mumbai | 0x294003F602c321627152c6b7DED3EAb5bEa853Ee | 0x5f3EFA9A90532914545CEf527C530658af87e196 |
|
2023-01-27 00:40:17 +00:00
|
|
|
|
|
|
|
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
|
|
|
|
|
|
|
|
<!-- https://goerli.etherscan.io/address/0x294003F602c321627152c6b7DED3EAb5bEa853Ee#code -->
|
|
|
|
|
|
|
|
<!-- https://goerli.etherscan.io/address/0x5f3EFA9A90532914545CEf527C530658af87e196#code -->
|
|
|
|
|
|
|
|
<!-- https://mumbai.polygonscan.com/address/0x294003F602c321627152c6b7DED3EAb5bEa853Ee#code -->
|
|
|
|
|
|
|
|
<!-- https://mumbai.polygonscan.com/address/0x5f3EFA9A90532914545CEf527C530658af87e196#code -->
|
|
|
|
|
|
|
|
### V2
|
2023-02-14 21:40:02 +00:00
|
|
|
|
2023-02-14 22:56:34 +00:00
|
|
|
| Testnet | Token Address | P2pix Address | Reputation Address | Multicall Address |
|
|
|
|
| ------- | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
|
|
|
|
| Goerli | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x2414817FF64A114d91eCFA16a834d3fCf69103d4 | 0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A | 0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6 |
|
|
|
|
| Mumbai | 0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29 | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x570445E3eF413bCDb5De79ed27B1c3840683e385 | 0x718B2C4DE4F9654E1349F610ff561249bfe1c418 |
|
2023-01-27 00:40:17 +00:00
|
|
|
|
|
|
|
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
|
|
|
|
<!-- https://goerli.etherscan.io/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
|
2023-02-14 22:56:34 +00:00
|
|
|
<!-- https://goerli.etherscan.io/address/0x2414817FF64A114d91eCFA16a834d3fCf69103d4#code -->
|
|
|
|
<!-- https://goerli.etherscan.io/address/0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A#code -->
|
|
|
|
<!-- https://goerli.etherscan.io/address/0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6#code -->
|
2023-01-27 04:50:37 +00:00
|
|
|
|
2023-01-27 00:40:17 +00:00
|
|
|
<!-- https://mumbai.polygonscan.com/address/0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29#code -->
|
2023-02-14 22:56:34 +00:00
|
|
|
<!-- https://mumbai.polygonscan.com/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
|
|
|
|
<!-- https://mumbai.polygonscan.com/address/0x570445e3ef413bcdb5de79ed27b1c3840683e385#code -->
|
|
|
|
<!-- https://mumbai.polygonscan.com/address/0x718B2C4DE4F9654E1349F610ff561249bfe1c418#code -->
|
2023-01-27 04:50:37 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
## Usage
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
### Pre Requisites
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
Before installing, create a `.env` file and set a BIP-39 compatible mnemonic and other env criteria as in `.env.example`.
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
### Install
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
```sh
|
|
|
|
$ yarn install
|
2022-10-25 13:23:49 +00:00
|
|
|
```
|
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
### Compile
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ yarn compile
|
2022-11-09 19:35:37 +00:00
|
|
|
```
|
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
**_NOTE:_** TypeChain artifacts generated at compile time.
|
2022-11-09 19:35:37 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
### Test
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
```sh
|
|
|
|
$ yarn test
|
2022-10-25 13:23:49 +00:00
|
|
|
```
|
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
### Report Gas
|
2022-11-08 19:06:25 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
```sh
|
|
|
|
$ REPORT_GAS=true yarn test
|
2022-11-08 19:06:25 +00:00
|
|
|
```
|
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
**_NOTE_:** Gas usage per unit test and average gas per method call.
|
|
|
|
|
|
|
|
### Clean
|
|
|
|
|
|
|
|
Delete the smart contract artifacts and cache:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ yarn clean
|
2022-11-08 19:06:25 +00:00
|
|
|
```
|
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
## Importing artifacts
|
|
|
|
|
|
|
|
To import artifacts on the project use the following:
|
|
|
|
|
|
|
|
```ts
|
2022-12-03 04:17:48 +00:00
|
|
|
import P2PIXArtifact from "p2pix-smart-contracts/artifacts/contracts/p2pix.sol/P2PIX.json";
|
2022-11-08 19:06:25 +00:00
|
|
|
```
|
2022-11-14 12:34:53 +00:00
|
|
|
|
|
|
|
To grab deployment addresses you can just grab from deploys folder:
|
|
|
|
|
|
|
|
```ts
|
2022-12-03 04:17:48 +00:00
|
|
|
import localhostDeploys from "p2pix-smart-contracts/deploys/localhost.json";
|
2022-11-08 19:06:25 +00:00
|
|
|
```
|
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
## Deploying to local environment
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
On the first teminal, use the following command and import some wallets to your Metamask, then connect to the network pointed:
|
2022-10-25 13:23:49 +00:00
|
|
|
|
2022-11-14 12:34:53 +00:00
|
|
|
```sh
|
|
|
|
yarn hardhat node
|
2022-10-25 13:23:49 +00:00
|
|
|
```
|
2022-11-14 12:34:53 +00:00
|
|
|
|
|
|
|
On the second teminal, run the following commands:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
yarn deploy1:localhost
|
|
|
|
yarn deploy2:localhost
|
2022-10-25 13:23:49 +00:00
|
|
|
```
|
2022-11-14 12:34:53 +00:00
|
|
|
|
|
|
|
**_NOTE_:** The second script transfers 2M tokens to the first wallet of the node.
|
|
|
|
To use the P2Pix smart contract first transfer some of the tokens to other wallets.
|
2023-01-27 00:40:17 +00:00
|
|
|
|
|
|
|
## Deploying to testnets
|
|
|
|
|
|
|
|
Deploy to Ethereum's Goerli testnet:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
yarn deploy1:goerli
|
|
|
|
yarn deploy2:goerli
|
|
|
|
```
|
|
|
|
|
|
|
|
Deploy to Polygon's Mumbai testnet:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
yarn deploy1:mumbai
|
|
|
|
yarn deploy2:mumbai
|
2023-02-14 21:40:02 +00:00
|
|
|
```
|