Skip to content

Latest commit

 

History

History
76 lines (50 loc) · 1.94 KB

README.md

File metadata and controls

76 lines (50 loc) · 1.94 KB

Voting

Build your first decentralized application, or dApp, on the Bitcoin with this tutorial.

LIVE DEMO 🚀

Step 1. Clone the project

$ git clone https://github.com/sCrypt-Inc/voting.git

Step 2. Install dependencies

$ cd voting
$ npm install

Step 3. Compile contract

$ npx scrypt-cli compile

Step 4. Add your API Key

Use your own API key in file index.tsx. If you don't have it, please follow this guide to get one.

Scrypt.init({
  apiKey: 'YOUR_API_KEY',  // <---
  network: 'testnet'
})

Step 5. Deploy contract

Before deploying the contract, create a .env file and save your private key in the PRIVATE_KEY environment variable.

PRIVATE_KEY=xxxxx

If you don't have a private key, please follow this guide to generate one using Sensilet wallet, then fund the private key's address with our faucet.

Run the following command to deploy the contract.

$ npm run deploy:contract

After success, you will see an output similar to the following:

Copy the deployment TxID then change the value of ContractId in file src/App.tsx:

const contract_id = {
  txId: "bccf73c0f49920fdbd2c66972b6ab14ac098239c429176acf5e599acb7dc6d4a",
  outputIndex: 0,
};

Step 6. Run the frontend app

$ npm start

Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.

If you're interested in how to build this dApp step by step, please refer to this guide for more details.