Skip to content

Commit

Permalink
Move tutorials code into this repo
Browse files Browse the repository at this point in the history
  • Loading branch information
fede@thinkpad committed Apr 13, 2020
1 parent a5eca78 commit 34830d9
Show file tree
Hide file tree
Showing 24 changed files with 34,726 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Buidler files
cache
artifacts
node_modules
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Buidler Hackathon Boilerplate

Create dapps with no build configuration.

## Quick Overview

Open a terminal, clone this repository and run:

```
npm install
npx buidler node
```

On a new terminal, go to this repository root folder and run:

```
npx buidler run scripts/deploy-frontend.js --network localhost
cd frontend
npm start
```

Then open http://localhost:3000/ to see your dapp. You will need to have Metamask installed and listening to `Localhost 8545`.


3 changes: 3 additions & 0 deletions buidler.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
usePlugin("@nomiclabs/buidler-waffle");

module.exports = {};
67 changes: 67 additions & 0 deletions contracts/Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Every contract should start with `pragma Solidity`.
// This will be used by the Solidity compiler.
pragma solidity ^0.5.15;

import "@nomiclabs/buidler/console.sol";

/**
* This is the main building block for smart contracts.
*/
contract Token {

// Some string type variables to identify the token.
string public name = "My Buidler Token";
string public symbol = "MBT";

// The fixed amount of tokens stored in an unsigned integer type variable.
uint256 public totalSupply = 1000;

// An address type variable is used to store ethereum accounts.
address public owner = address(0);

// A mapping is a key/value map. Here we store each account balance.
mapping(address => uint256) balances;

/**
* Contract initialization.
*
* The `constructor` is executed only once when the contract is created.
* The `public` modifier makes a function callable from outside the contract.
*/
constructor() public {

// The totalSupply is assigned to transaction sender, which is the account
// that is deploying the contract.
balances[msg.sender] = totalSupply;
owner = msg.sender;
}

/**
* A function to transfer tokens.
*
* The `external` modifier makes a function *only* callable from outside
* the contract.
*/
function transfer(address to, uint256 amount) external {
// Check if the transaction sender has enough tokens.
// If `require` evaluates `false` then the transaction will revert.
require(balances[msg.sender] >= amount, "Not enough tokens");

console.log("Transferring from %s to %s %s tokens", msg.sender, to, amount);

// Transfer the amount.
balances[msg.sender] -= amount;
balances[to] += amount;
}

/**
* Read only function to retrieve the token balance of a given account.
*
* The `view` modifier allows us to call this function without executing a
* transaction.
*/
function balanceOf(address account) external view returns (uint256) {
return balances[account];
}

}
23 changes: 23 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
68 changes: 68 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

### Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

### Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

### Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

### Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

### `npm run build` fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
Loading

0 comments on commit 34830d9

Please sign in to comment.