CryptoGive is a platform for donating to your choice of charity programs with cryptocurrency.
Home View | Donations View |
---|---|
Donation platforms already exist – how is one based on a public blockchain an improvement?
The platform owner can register charities, who in turn register programs/campaigns. Potential donors select from the active programs available and donate an amount in ether (which is then transferred to the address of the charity).
The owner is the address that deployed the contract. The owner can:
A charity must first be registered by the owner. A registered charity can:
Anyone can be a donor to any active program, and see their own past donations.
CryptoGive is a standard-configured Truffle project with few dependencies. The client app is stateless and written in vanilla JavaScript, with each page loading only the scripts it needs. Other than the contract migrations, the project does not require a build process.
It uses ethers.js
and MetaMask as providers and the wallet.
The project UI is publicly available at https://blockchain-bootcamp-project.web.app/, which uses the deployed contract on the Ropsten network.
To develop the project locally, you will need Truffle v5.4.15 or higher (Truffle's own requirements are Node v8.9.4 or later, and Linux, MacOS, or Windows).
contracts/
: Solidity contracts – the project's only contract is Fundraisers.sol
.notes/
: Initial exploration.src/
: Client app.test/
: Unit tests for the contract in JS.node -v
to verify your Node version is at least v8.9.4. If not, follow Node's instructions for installation or updating.truffle --version
to verify your Truffle installation is at least v5.4.15. If not, follow their instructions to update or install it (try npm install -g truffle
for the latest version).git clone git@github.com:kwight/blockchain-developer-bootcamp-final-project.git
(assumes you have SSH keys set up – HTTPS will work fine too).cd
into the root of your cloned repo.npm install
to fetch the package dependencies.truffle develop
. This will start up a local blockchain and give you a console.development
network in truffle-config.js
.migrate --reset
.f = await Fundraisers.deployed()
.f.address
to get the contract's local address, and enter it on this line./src
. In that directory in a different terminal window (keep the development console running), run npx serve
and open the given URL in your browser. Any local webserver service run from that directory will also work.test
to verify the contract unit tests all pass.You're all set – you've got a console with access to the deployed contract on the local blockchain, and a front-end in your browser that's using the local blockchain as its data source.
Here are some commands you can use to interact with the contract from the console. These assume you've set the f
variable from the installation notes above. Remember that on the local blockchain, the contract owner is the accounts[0]
account (which is the default from:
value when one isn't specified). If the client UI is open while running commands on the console, it will update automatically.
f.registerCharity(accounts[1], 'SPCA')
f.registerProgram('Cat Adoption', {from: accounts[1]})
f.registerProgram('Dog Rescue', {from: accounts[1]})
f.getPrograms()
f.completeProgram(0, {from: accounts[1]})
f.donate(1, {from: accounts[9], value:55555555555555})
The project uses dotenv
for managing keys when deploying to public networks. Create a local .env
file (which is gitignored) with the following constants. Ropsten is already configured (other networks would need to be added to truffle-config.js
).
PRIVATE_KEY
: Private key of the account that should be owner on deployment.INFURA_URL
: Infura URL with the project ID.Address for certification: kwight.eth (0x0808832994E697C9c1A3e76a60A7e0c75e52348a)