Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scrypt-inc/voting
https://github.com/scrypt-inc/voting
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/scrypt-inc/voting
- Owner: sCrypt-Inc
- Created: 2023-04-11T14:26:43.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-29T13:35:35.000Z (8 months ago)
- Last Synced: 2024-05-30T03:33:56.424Z (8 months ago)
- Language: TypeScript
- Homepage: http://classic.scrypt.io/voting/
- Size: 13.1 MB
- Stars: 9
- Watchers: 3
- Forks: 5
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Voting
Build your first decentralized application, or dApp, on the Bitcoin with this tutorial.
[LIVE DEMO](http://classic.scrypt.io/voting/) 🚀
## Step 1. Clone the project
```bash
$ git clone https://github.com/sCrypt-Inc/voting.git
```## Step 2. Install dependencies
```bash
$ cd voting
$ npm install
```## Step 3. Compile contract
```bash
$ 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](https://docs.scrypt.io/advanced/how-to-integrate-scrypt-service#get-your-api-key) to get one.
```ts
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.
```text
PRIVATE_KEY=xxxxx
```If you don't have a private key, please follow [this guide](https://scrypt.io/docs/how-to-deploy-and-call-a-contract/#setup) to generate one using [Sensilet](https://sensilet.com/) wallet, then fund the private key's address with our [faucet](https://scrypt.io/faucet/).
Run the following command to deploy the contract.
```bash
$ npm run deploy:contract
```After success, you will see an output similar to the following:
![](https://aaron67-public.oss-cn-beijing.aliyuncs.com/202305060511743.png)
Copy the deployment TxID then change the value of `ContractId` in file `src/App.tsx`:
```ts
const contract_id = {
txId: "bccf73c0f49920fdbd2c66972b6ab14ac098239c429176acf5e599acb7dc6d4a",
outputIndex: 0,
};
```## Step 6. Run the frontend app
```bash
$ npm start
```Runs the app in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
![](https://aaron67-public.oss-cn-beijing.aliyuncs.com/202305060521385.gif)
If you're interested in how to build this dApp step by step, please refer to this [guide](https://scrypt.io/docs/tutorials/voting/) for more details.