Skip to content

Commit f037d4a

Browse files
committed
Initialize Truffle
1 parent a139efd commit f037d4a

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/migrations

Diff for: contracts/Migrations.sol

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity >=0.4.21 <0.6.0;
2+
3+
contract Migrations {
4+
address public owner;
5+
uint public last_completed_migration;
6+
7+
constructor() public {
8+
owner = msg.sender;
9+
}
10+
11+
modifier restricted() {
12+
if (msg.sender == owner) _;
13+
}
14+
15+
function setCompleted(uint completed) public restricted {
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) public restricted {
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}

Diff for: migrations/1_initial_migration.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const Migrations = artifacts.require("Migrations");
2+
3+
module.exports = function(deployer) {
4+
deployer.deploy(Migrations);
5+
};

Diff for: truffle-config.js

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* Use this file to configure your truffle project. It's seeded with some
3+
* common settings for different networks and features like migrations,
4+
* compilation and testing. Uncomment the ones you need or modify
5+
* them to suit your project as necessary.
6+
*
7+
* More information about configuration can be found at:
8+
*
9+
* truffleframework.com/docs/advanced/configuration
10+
*
11+
* To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
12+
* to sign your transactions before they're sent to a remote public node. Infura accounts
13+
* are available for free at: infura.io/register.
14+
*
15+
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
16+
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
17+
* phrase from a file you've .gitignored so it doesn't accidentally become public.
18+
*
19+
*/
20+
21+
// const HDWalletProvider = require('truffle-hdwallet-provider');
22+
// const infuraKey = "fj4jll3k.....";
23+
//
24+
// const fs = require('fs');
25+
// const mnemonic = fs.readFileSync(".secret").toString().trim();
26+
27+
module.exports = {
28+
/**
29+
* Networks define how you connect to your ethereum client and let you set the
30+
* defaults web3 uses to send transactions. If you don't specify one truffle
31+
* will spin up a development blockchain for you on port 9545 when you
32+
* run `develop` or `test`. You can ask a truffle command to use a specific
33+
* network from the command line, e.g
34+
*
35+
* $ truffle test --network <network-name>
36+
*/
37+
networks: {
38+
// Useful for testing. The `development` name is special - truffle uses it by default
39+
// if it's defined here and no other network is specified at the command line.
40+
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
41+
// tab if you use this network and you must also set the `host`, `port` and `network_id`
42+
// options below to some value.
43+
//
44+
// development: {
45+
// host: "127.0.0.1", // Localhost (default: none)
46+
// port: 8545, // Standard Ethereum port (default: none)
47+
// network_id: "*", // Any network (default: none)
48+
// },
49+
// Another network with more advanced options...
50+
// advanced: {
51+
// port: 8777, // Custom port
52+
// network_id: 1342, // Custom network
53+
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
54+
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
55+
// from: <address>, // Account to send txs from (default: accounts[0])
56+
// websockets: true // Enable EventEmitter interface for web3 (default: false)
57+
// },
58+
// Useful for deploying to a public network.
59+
// NB: It's important to wrap the provider as a function.
60+
// ropsten: {
61+
// provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
62+
// network_id: 3, // Ropsten's id
63+
// gas: 5500000, // Ropsten has a lower block limit than mainnet
64+
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
65+
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
66+
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
67+
// },
68+
// Useful for private networks
69+
// private: {
70+
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
71+
// network_id: 2111, // This network is yours, in the cloud.
72+
// production: true // Treats this network as if it was a public net. (default: false)
73+
// }
74+
},
75+
// Set default mocha options here, use special reporters etc.
76+
mocha: {
77+
// timeout: 100000
78+
},
79+
// Configure your compilers
80+
compilers: {
81+
solc: {
82+
// version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version)
83+
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
84+
// settings: { // See the solidity docs for advice about optimization and evmVersion
85+
// optimizer: {
86+
// enabled: false,
87+
// runs: 200
88+
// },
89+
// evmVersion: "byzantium"
90+
// }
91+
}
92+
}
93+
};

0 commit comments

Comments
 (0)