GithubHelp home page GithubHelp logo

lukasvozda / bitshop Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 3.0 1.36 MB

Bitshop if a proof of concept project that demonstrates capabilities of the Internet Computer blockchain. It is a Shopify alternative running 100 % on-chain with Bitcoin as a native payment.

Home Page: https://www.bitshop.info

License: Apache License 2.0

JavaScript 11.46% Motoko 31.29% HTML 0.52% TypeScript 12.75% Svelte 42.49% CSS 0.47% Dhall 1.03%
bitcoin cryptocurrency internetcomputer dfinity icp

bitshop's Introduction

About this project

Bitshop if a proof of concept project that demonstrates capabilities of the Internet Computer blockchain. It is a Shopify alternative running 100 % on-chain with Bitcoin as a native payment. There is no need to install any additional software to use this app โ€“ it is all approachable via web browser.

We implemented CRUD support for products, categories, orders. You can also upload images for each product that are also stored on-chain.

Unique BTC address is generated for each order โ€“ the backend is able to verify the payment automatically.

We used Sveltekit to build the frontend of this app and the backend is written in the Motoko language, designed to write smart contracts on the IC. All code is open source in this repository.

These features are missing in order to be able to run an online store on Bitshop in real world:

  • Product Variants
  • E-mail confirmations
  • Shipping providers integrations
  • More payment methods (USDC, ETH, VISA)
  • Support for discounts
  • Tax and invoices
  • Multiple images support

If you would like to use Bitshop for your own projects, please let us know what features are most important to you.

[email protected]

https://twitter.com/bitshopicp

Getting started

Make sure you have node.js installed.

clone this repo
npm ci

DFX

Install dfx by running

sh -ci "$(curl -fsSL https://smartcontracts.org/install.sh)"

vessel

Install vessel by running

wget -qO /usr/local/bin/vessel https://github.com/dfinity/vessel/releases/download/v0.6.5/vessel-linux64
chmod +x /usr/local/bin/vessel

Note if you have a different OS, you can find the correct version here.

Start and stop the local replica

Open a new terminal window in the project directory, and run the following command to start the local replica. The replica will not start unless dfx.json exists in the current directory.

dfx start --background

When you're done with development, or you're switching to a different dfx project, running

dfx stop

from the project directory will stop the local replica.

Configuration

DFX

To connect to the Bitcoin network, you need to specify address to your (or remote) Bitcoin node in the dfx.json file.

"bitcoin": {
  "enabled": true,
  "nodes": ["node1-ip:port", "node2-ip:port"],
  "log_level": "info"
},

You can also achieve the same by running command:

dfx start --enable-bitcoin --bitcoin-node 127.0.0.1:<your_custom_port>

See Internet Computer Bitcoin development page for more details.

Motoko

dfx.json unfortunately does not support configuration of the Motoko backend. You can configure the network parameters in the src/backend/src/config.mo. The possible values are:

#Mainnet
#Testnet
#Regtest

Build & run the dapp

To build and deploy the project locally run

dfx deploy

When the process completes you'll have a frontend canister running locally. To find the frontend canister's ID, run

dfx canister id frontend

It will output something similar to rno2w-sqaaa-aaaaa-aaacq-cai. Copy this ID and open it in the browser using http://<canister ID>localhost:8000, eg. http://rno2w-sqaaa-aaaaa-aaacq-cai.localhost:8000.

Local development

You can serve the frontend in development mode like you normally develop an app using the command

npm run dev

it is not necessary to deploy it to the frontend canister during development.

Deploying to the IC

To host the Svelte app on the IC, you'll need to have some cycles available. Cycles pay for the execution of your app, and they are also needed to create canisters.

You can get $20 worth of cycles for free from the Cycles Faucet.

You should have a canister running the cycles wallet on the IC at this point. The cycles wallet makes it easy to pay for canister creation.

You can check the balance by running

dfx wallet --network ic balance

After making sure you have cycles available you can run

dfx deploy --network ic

The command will build the project, create a new canister on the IC and deploy the Svelte app into it. The command will also create a new file canister_ids.json which will help the dfx tool deploy to the same canister in future updates. You can commit this file in your repository.

You can now open your Svelte app running on the IC. You can find the canister ID in the deploy command output, or use the ID in canister_ids.json.

The link to your app is <canister_id>.ic0.app. For example if your canister ID is zgvi5-hiaaa-aaaam-aaasq-cai, your app will be at https://zgvi5-hiaaa-aaaam-aaasq-cai.ic0.app/.

bitshop's People

Contributors

lukasvozda avatar martinagrzybowska avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.