Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
@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;
@alexroan
alexroan / entryPoint.test.js
Created March 21, 2020 17:12
truffle-tests/entryPoint.test.js
const EntryPoint = artifacts.require("./EntryPoint.sol");
require('chai')
.use(require('chai-as-promised'))
.should();
contract("EntryPoint", accounts => {
describe("Storing Values", () => {
it("Stores correctly", async () => {
const entryPoint = await EntryPoint.deployed();
@alexroan
alexroan / 2_deploy_contracts.js
Last active March 22, 2020 21:50
truffle-multiple-migrations-1.js
const MyERC20 = artifacts.require("MyERC20");
module.exports = function(deployer) {
deployer.deploy(MyERC20);
};
@alexroan
alexroan / 2_deploy_contracts.js
Created March 22, 2020 21:54
truffle-multiple-migrations-2.js
const MyERC20 = artifacts.require("MyERC20");
const SecondERC20 = artifacts.require("SecondERC20");
module.exports = function(deployer) {
deployer.deploy(MyERC20);
deployer.deploy(SecondERC20);
};
@alexroan
alexroan / 2_deploy_contracts.js
Created March 22, 2020 22:02
truffle-multiple-migrations-3.js
const MyERC20 = artifacts.require("MyERC20");
const SecondERC20 = artifacts.require("SecondERC20");
module.exports = function(deployer) {
// deploy the first
deployer.deploy(MyERC20);
// get the owner address
const accounts = await web3.eth.getAccounts();
const owner = accounts[0];
@alexroan
alexroan / 2_deploy_contracts.js
Created March 22, 2020 22:12
truffle-multiple-migrations-4.js
const MyERC20 = artifacts.require("MyERC20");
const Exchange = artifacts.require("Exchange");
module.exports = async function(deployer) {
// deploy MyERC20 and store return value
let erc20 = await deployer.deploy(MyERC20);
// deploy the Exchange and pass erc20
deployer.deploy(Exchange, erc20);
};
@alexroan
alexroan / DataTypes.sol
Last active March 24, 2020 15:28
examples/solidity-data-types
pragma solidity >=0.5.0;
contract DataTypes {
// Boolean
bool trueOrFalse;
// Unsigned integer. default size is 256
uint firstInteger;
// The same as above, with definition
uint256 secondInteger;
// Signed integer, 128