Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
@alexroan
alexroan / TestHelloWorld.sol
Created March 17, 2020 08:17
truffle-smart-contract/TestHelloWorld.sol/0.0.5
pragma solidity >=0.5.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/HelloWorld.sol";
contract TestHelloWorld {
function testItGreets() public {
// Get the deployed contract
HelloWorld helloWorld = HelloWorld(DeployedAddresses.HelloWorld());
@alexroan
alexroan / truffle-config.js
Created March 17, 2020 10:37
truffle-smart-contract/truffle-config.js/0.0.6
const HDWalletProvider = require('truffle-hdwallet-provider-privkey');
const privateKey = "private-key-goes-here";
const endpointUrl = "endpoint-goes-here";
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "5777",
@alexroan
alexroan / package.json
Created March 17, 2020 11:49
truffle-smart-contract/package.json/0.0.6
{
"dependencies": {
"truffle-hdwallet-provider": "1.0.4",
"truffle-hdwallet-provider-privkey": "1.0.3",
"web3": "1.0.0-beta.46"
}
}
@alexroan
alexroan / truffle-config.js
Created March 20, 2020 12:52
truffle-dapp/truffle-config.js/0.0.1
const path = require("path");
module.exports = {
contracts_build_directory: path.join(__dirname, "client/src/contracts"),
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "5777",
}
@alexroan
alexroan / 2_deploy_contracts.js
Created March 20, 2020 15:24
2_deploy_contracts.js/truffle-dapp/0.0.1
const HelloWorld = artifacts.require("HelloWorld");
const SimpleStorage = artifacts.require("SimpleStorage");
module.exports = function(deployer) {
deployer.deploy(HelloWorld);
deployer.deploy(SimpleStorage);
};
@alexroan
alexroan / Background.sol
Created March 21, 2020 17:08
truffle-tests/Background.sol
pragma solidity >=0.5.0;
contract Background {
uint[] private values;
function storeValue(uint value) public {
values.push(value);
}
function getValue(uint initial) public view returns(uint) {
@alexroan
alexroan / EntryPoint.sol
Created March 21, 2020 17:09
truffle-tests/EntryPoint.sol
pragma solidity >=0.5.0;
import "./Background.sol";
contract EntryPoint {
address public backgroundAddress;
constructor(address _background) public{
backgroundAddress = _background;
}
@alexroan
alexroan / TestBackground.sol
Created March 21, 2020 17:09
truffle-tests/TestBackground.sol
pragma solidity >=0.5.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../../../contracts/Background.sol";
contract TestBackground {
Background public background;
@alexroan
alexroan / TestEntryPoint.sol
Created March 21, 2020 17:11
truffle-tests/TestEntryPoint.sol
pragma solidity >=0.5.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../../../contracts/Background.sol";
import "../../../contracts/EntryPoint.sol";
contract TestEntryPoint {
// Ensure that dependency injection working correctly
@alexroan
alexroan / TestIntegrationEntryPoint.sol
Created March 21, 2020 17:11
truffle-tests/TestIntegrationEntryPoint.sol
pragma solidity >=0.5.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../../../contracts/Background.sol";
import "../../../contracts/EntryPoint.sol";
contract TestIntegrationEntryPoint {
BackgroundTest public backgroundTest;