Coder Social home page Coder Social logo

cryptobnb's Introduction

Tutorial Series "cryptobnb"

Crypto bed and breakfast (Airbnb) example dapp tutorial done in stages.

These examples slowly build from a basic hello world example in v0 and v1 into a multi smart contract architecture using open-zeppelin contracts and 3 custom contracts.

Getting Started (install)

In order to get started you're going to a need a Solidty smart contract development tool called truffle and you can install it using:

npm i -g truffle

Double check this installation went ok using:

truffle version

You should see a version number pop out.

Now you can hop into one of the sub folders like v0 and open the truffle development console.

Truffle Developer Console

Once inside a directory with a typical truffle file structure:

contracts/
migrations/
test/
truffle-config.js
truffle.js
...

You can launch the truffle developer console using:

truffle develop

What does this do?

This launches a test blockchain on your device with 10 unlocked accounts, each containing 100 ether.

From inside your project folder and inside the developer console you can use the following truffle commands:

init      Initialize new and empty Ethereum project
compile   Compile contract source files
migrate   Run migrations to deploy contracts
deploy    (alias for migrate)
build     Execute build pipeline (if configuration present)
test      Run JavaScript and Solidity tests
debug     Interactively debug any transaction on the blockchain (experimental)
opcode    Print the compiled opcodes for a given contract
console   Run a console with contract abstractions and commands available
develop   Open a console with a local development blockchain
create    Helper to create new contracts, migrations and tests
install   Install a package from the Ethereum Package Registry
publish   Publish a package to the Ethereum Package Registry
networks  Show addresses for deployed contracts on each network
watch     Watch filesystem for changes and rebuild the project automatically
serve     Serve the build directory on localhost and watch for changes
exec      Execute a JS module within this Truffle environment
unbox     Download a Truffle Box, a pre-built Truffle project
version   Show version number and exit

You can look at these commands anytime by typing truffle in the command line (outside the developer console)

Testing Contracts

The most important thing we're going to do with some of the early tutorials is test our smart contracts using javascript and the truffle developer console test runner.

The test runner uses the mocha / chai test framework if you're familiar. If not, don't worry it's simple.

You can run tests from the developer consoler by simply typing:

test

And outside the developer console by typing:

truffle test

However, each time you run the tests outside the developer console, truffle needs to spin up a whole new blockchain for testing.

It's much better to have 1 terminal window live in the developer console for running tests.

Wrapping Up

That covers getting started with truffle.

Each sub-folder has it's own README.md where the smart contracts are explained in detail.

For additional installation instructions, running front-ends etc... these can also be found in the sub-folder tutorial README.md.

Happy Truffling :)

cryptobnb's People

Contributors

mattlockyer avatar dev43 avatar

Watchers

James Cloos 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.