Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neutral #98

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEUTRAL/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/babel", "next/core-web-vitals"]
}
36 changes: 36 additions & 0 deletions NEUTRAL/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions NEUTRAL/OffsetHelper
Submodule OffsetHelper added at 408553
43 changes: 43 additions & 0 deletions NEUTRAL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## NEUTRAL - Offset your crypto transactions

### Team web3000

#### DeFi

##### Region - APAC

##### Team Members

- Mayur Samrutwar, full stack developer

#### Project Description

Offset your transactions on blockchain and be a carbon neutral.

#### Summary

Transactions occuring on blockchain envolves emission of CO2 in the environment. It's our moral responsibility to
offset the carbon we emitted into the atmosphere.

**Neutral** helps you to make yourself carbon neutral.

- Connect Wallet or enter address manually.
- Click on calculate button to calculate your carbon emission.
- See how neutral you are and offset remaining carbon using Toucon protocol.

#### URLs

List any URLs relevant to demonstrating your prototype

#### Presentation

https://drive.google.com/drive/folders/13jh18bfKjbs6HNprv-Z_lzgfzAnW6QVS?usp=sharing

#### Next Steps

- Implement Toucon protocol
- Add transactions from majority of the EVM chains and non-EVM chains.

#### License

This repository includes an [unlicensed](http://unlicense.org/) statement though you may want to [choose a different license](https://choosealicense.com/).
83 changes: 83 additions & 0 deletions NEUTRAL/comps/SendTransaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import * as React from "react";
import { useEffect } from "react";
import { useDebounce } from "use-debounce";
import {
usePrepareContractWrite,
useContractWrite,
useWaitForTransaction,
} from "wagmi";
import { useRouter } from "next/router";

export function SendTransaction() {
const Router = useRouter();

function redirectToResult() {
Router.push({
pathname: "/result",
query: {
percentage: 100,
},
});
}

useEffect(() => {
setTimeout(() => redirectToResult(), 15000);
});

const { config } = usePrepareContractWrite({
address: "0x1Da87eA2610CAF5192804407EeeA840C670bF0E1",
abi: [
{
inputs: [],
stateMutability: "nonpayable",
type: "constructor",
},
{
inputs: [],
name: "updateCarbonOffset",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "_address",
type: "address",
},
],
name: "viewCarbonOffset",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
],
functionName: "updateCarbonOffset",
});
const { data, write } = useContractWrite(config);

const { isLoading, isSuccess } = useWaitForTransaction({
hash: data?.hash,
});

return (
<div>
<button
className="p-4 rounded bg-black text-white mt-8"
disabled={!write || isLoading}
onClick={() => write()}
>
{isLoading ? "Retiring..." : "Retire Carbon"}
</button>

{isSuccess && redirectToResult}
</div>
);
}
11 changes: 11 additions & 0 deletions NEUTRAL/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

#Hardhat files
cache
artifacts

13 changes: 13 additions & 0 deletions NEUTRAL/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.js
```
14 changes: 14 additions & 0 deletions NEUTRAL/contracts/contracts/Neutral.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

contract Neutral {
mapping (address => uint) offsetTillNow;

function updateCarbonOffset(address _address, uint _carbonToBeAdded) public{
offsetTillNow[_address] += _carbonToBeAdded;
}

function viewCarbonOffset(address _address) public view returns(uint){
return offsetTillNow[_address];
}
}
17 changes: 17 additions & 0 deletions NEUTRAL/contracts/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config({ path: ".env" });

const QUICKNODE_HTTP_URL = process.env.QUICKNODE_HTTP_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;

// 0x7Bd6604e45A25630EfB009C96d03a99EF14b72cB

module.exports = {
solidity: "0.8.17",
networks: {
celo: {
url: QUICKNODE_HTTP_URL,
accounts: [PRIVATE_KEY],
},
},
};
Loading