Skip to content

Instantly share code, notes, and snippets.

View m-yahya's full-sized avatar
🛠️
Building Stuff

Muhammad Yahya m-yahya

🛠️
Building Stuff
View GitHub Profile
Ganache CLI v6.1.8 (ganache-core: 2.2.1)
Available Accounts
==================
(0) 0x5a610c431673ac449a3b340fa55d5ce03f6719f8 (~100 ETH)
(1) 0xf96c3666fc20f74389811287d3dbbb2d7830d8c4 (~100 ETH)
(2) 0xc0161bd0d39765bfcc3c3317b576ee7813fe5a0c (~100 ETH)
(3) 0x35ef9eba8886cb69f409b79299325cf36ec89e87 (~100 ETH)
(4) 0xc25e0bb5e37bf9bbb72a81527ee504be62c7f380 (~100 ETH)
(5) 0x813a1b2267f722c9f0d5de6290ba985fbd13e96e (~100 ETH)
Downloading...
Unpacking...
Setting up...
Unbox successful. Sweet!
Commands:
Compile: truffle compile
Migrate: truffle migrate
Test contracts: truffle test
C:.
| truffle-config.js
| truffle.js
|
+---contracts
| Migrations.sol
|
+---migrations
| 1_initial_migration.js
|
module.exports = {
networks:{
development:{
host: '127.0.0.1',
port: 8545,
network_id: '*' // match any netwrok id
}
}
};
pragma solidity ^0.4.22;
contract SimpleContract {
string public name;
constructor() {
name = 'my name';
}
function getName() public view returns (string) {
Compiling .\contracts\Migrations.sol...
Compiling .\contracts\SimpleContract.sol...
Compilation warnings encountered:
/D/GitHub/truffle-demo/contracts/SimpleContract.sol:6:3: Warning: No visibility specified. Defaulting to "public".
constructor() {
^ (Relevant source part starts here and spans across multiple lines).
Writing artifacts to .\build\contracts
const SimpleContract = artifacts.require('SimpleContract');
module.exports = function(deployer) {
// Use deployer to state migration tasks.
deployer.deploy(SimpleContract);
};
Using network 'development'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0xa3995d03ac7b76f0def8714b6989ce68f04166f50aaeb8a8054ae51f546773ab
Migrations: 0x6b43963e6d7c07a98f3d4b726d62dcdc0b75ec5a
Saving successful migration to network...
... 0x1c8313e68853618011ec0e725b0a83c796c0c1477f7ea5a0e5ce4b25f9a51309
Saving artifacts...
Running migration: 1542014427_deploy_simple_contract.js
const SimpleContract = artifacts.require("SimpleContract");
contract('SimpleContract', (accounts) => {
it("should return the list of accounts", async ()=> {
console.log(accounts);
});
});
const SimpleContract = artifacts.require("SimpleContract");
contract('SimpleContract', (accounts) => {
it("should return the name", async ()=> {
const instance = await SimpleContract.deployed();
const value = await instance.getName();
assert.equal(value, 'my name');
});