Hello World!

pragma solidity ^0.5.10;

 

import './Deployable';

 

contract HelloWorld is Deployable {
    function helloWorld() public pure returns(string memory) {
        return "Hello world!";
    }
}

create-blockchain-app

Create blockchain decentralised application in no time.

A create-react-app but for blockchain dapp

hide the blockchain part for dapp developers

Why?

Programming is easy, developing application is hard

Technologies used in dapp developement:

Even harder with the blockchain part.

es5/es6, html, css, sass, jquery, ajax, xml, bootstrap, sql, nosql,

angluar/vuejs/reactjs, expressjs, aws, firebase, webpack/parcel, babel, git/github, node.js, jenkins, docker
solidity, remix, truffle/embark, ethers, web3, ganache, infura, ethereum, metamask, and all others blockchains.

 

 

Easy installation

2 command lines and you can start coding.

npm i -g create-blockchain-app
npx create-blockchain-app yourApp
cd yourApp && npm start

Front-end

Framework agnostic:

  • React
  • Vuejs (todo)
  • Flutter (todo)
  • Even raw javascript

parceljs

Dev environment with hot reload, files watchers, plugins

Blazing fast, zero configuration web application bundler

Contracts & Solidity

  • Auto compilation and deployment!

  • contracts functions are automatically exported as js functions
  • Security check
  • Administration page for testing contract

Metamask context

Metamask context is automatically injected in your app:

<MetamaskContext>
    <youDapp />
</MetamaskContext>

Metamask with react hooks:

 

const yourApp () => {
    const metamask = useMetamask();
    console.log(metamask.address);
    console.log(metamask.network);
    console.log(metamask.balance);
};

How it works?

sol2js: generate javascript from solidity file. And deploy contracts on the blockchain.
 
https://github.com/akersof/sol2js

parcel-plugin-solidity: automatically trigger sol2js when solidity files changed

https://github.com/akersof/parcel-plugin-solidity

create-blockchain-app: dev environment, web server, build.
https://github.com/akersof/create-blockchain-app 

How to use?

//Raw javascript
import {helloYou, goodbye} from './contracts/hello';
const res1 = await helloYou('bob');
const res2 = await goodbye('alice');
pragma solidity ^0.5.8;
import "./Deployable.sol";
contract hello is Deployable {
    function helloYou(string memory _name) public view returns(string memory){
        return string(abi.encodePacked("Hello"," ",_name));
    }
    function goodbye(string memory _name) public view returns(string memory){
        return string(abi.encodePacked("Goobye"," ",_name, ", see you soon"));
    }
}
//with react hook
import React from 'react';
import {helloYou, goodbye} from './contracts/hooks/hello.js';

function Dapp() {
    const [res1] = helloYou('bob');
    const [res2] = goodbye('alice');
    return (    <div>
                    {res1.status === "success" ? response.result : "Loading"}
                    <br />
                    {response2.status === "success" ? response2.result : "Loading"}
                </div>
    );
}

TODO?

Demo

Copy of create-blockchain-app

By Sofiane Akermoun

Copy of create-blockchain-app

  • 738