- Install the
Ganache Blockchain
:
$ npm install --global ganache-cli
- Get a
Web3
instance:
if (typeof web3 !== 'undefined') {
var VictimContract = eth.contract([ | |
{ | |
"constant": false, | |
"inputs": [], | |
"name": "withdraw", | |
"outputs": [], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, |
var BasicToken = artifacts.require("./BasicToken.sol"); | |
module.exports = function(deployer, network, accounts) { | |
deployer.deploy(BasicToken, 10000000000, accounts[0]); | |
}; |
pragma solidity ^0.4.18; | |
contract BasicToken { | |
mapping(address => uint256) balances; | |
string public constant NAME = "BasicToken"; | |
string public constant SYMBOL = "BTN"; | |
uint256 totalSupply_; | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
function BasicToken (uint256 INITIAL_SUPPLY, address _owner) { |
pragma solidity ^0.4.6; | |
contract WalletLibrary { | |
address public owner; | |
modifier onlyOwner() { | |
require(msg.sender == owner); | |
_; | |
} |
const WalletLibrary = artifacts.require("./WalletLibrary.sol"); | |
const Wallet = artifacts.require("./Wallet.sol"); | |
module.exports = function(deployer, network, accounts) { | |
deployer | |
.deploy(WalletLibrary) | |
.then(() => | |
deployer.deploy(Wallet, WalletLibrary.address, accounts[0]) | |
); | |
}; |
pragma solidity ^0.4.6; | |
contract Wallet { | |
address public owner; | |
address public _walletLibrary; | |
function Wallet(address libAddress, address _owner) public { | |
_walletLibrary = libAddress; | |
_walletLibrary.delegatecall(bytes4(keccak256("initWallet(address)")), _owner); | |
} |
pragma solidity ^0.4.6; | |
contract WalletLibrary { | |
address owner; | |
function initWallet(address _owner) { | |
owner = _owner; | |
} | |
function changeOwner(address _newOwner) external { |
module.exports = { | |
networks: { | |
development: { | |
host: "127.0.0.1", | |
port: 8545, | |
network_id: "*", | |
} | |
} | |
} |
Ganache Blockchain
:$ npm install --global ganache-cli
Web3
instance:if (typeof web3 !== 'undefined') {
$ git clone [email protected]:Jusdev89/Remix-Mini-Starter.git
mini_remix_stater
$ open index.html