Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.

BitskiCo/example-backend-dapp

Repository files navigation

Example Ethereum Backend App

This is a Node JS application that connects to the ethereum blockchain via Web3 and Bitski and interacts with a smart contract as a data source.

We built this example to show what is possible using Bitski's app wallet, and to experiment with patterns for interacting with ethereum server-side.

Our smart contract is a simple non-fungible token that can be minted for free, with a limit of 5 tokens per address. We allow our users to request a token by POST-ing to /tokens/new, and host the metadata of the token by reading from the smart contract.

Bitski's Node SDK allows you to easily read from Ethereum in Node, and with App Wallet you can also create server-side transactions.

Project Structure

Node app

The entry point is index.js, which simply creates an instance of App. The source code for that class is under /app/. App is responsible for creating the Express http server and handling the requests.

App creates an instance of Contract, which is just a wrapper around Web3's contract module, and truffle artifacts. It pulls in the compiled contract ABI (generated by Truffle), extracts the deployed address, and creates an instance of that contract with web3.

Check out app.js to see the various routes that are exposed.

Smart Contracts

Powering all the data for this app is an Ethereum smart contract. It's written in Solidity, and based off of OpenZeppelin's NFT templates. You can view the source code for the main contract under contracts/LimitedMintableNonFungibleToken.sol.

Running the demo

First, install the dependencies via NPM:

npm install

Next, create an app on Bitski's Developer Portal, create an App Wallet for your app, and enter your details into a .env file like so:

BITSKI_APP_WALLET_ID=YOUR-CREDENTIAL-ID-HERE
BITSKI_APP_WALLET_SECRET=YOUR-CREDENTIAL-SECRET-HERE

Finally, you can run the app with:

npm run start

Deploying the contract yourself

You can create a bitski.config.js and use Truffle to deploy your own version of this contract with your App Wallet.

About

Example of using App Wallet to automatically send requested transactions to users' wallets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors