This repository was archived by the owner on Jan 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +3389
-0
lines changed Expand file tree Collapse file tree 9 files changed +3389
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ pragma solidity >= 0.4.25 < 0.7.0 ;
3+
4+ library ConvertLib {
5+ struct TestStruct {
6+ uint256 name;
7+ }
8+
9+ function convert (uint amount ,uint conversionRate ) public pure returns (uint convertedAmount )
10+ {
11+ return amount * conversionRate;
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ pragma experimental ABIEncoderV2;
3+ pragma solidity >= 0.4.25 < 0.7.0 ;
4+
5+ import "./ConvertLib.sol " ;
6+
7+ // This is just a simple example of a coin-like contract.
8+ // It is not standards compatible and cannot be expected to talk to other
9+ // coin/token contracts. If you want to create a standards-compliant
10+ // token, see: https://github.com/ConsenSys/Tokens. Cheers!
11+
12+ contract MetaCoin {
13+ mapping (address => uint ) balances;
14+
15+ event Transfer (address indexed _from , address indexed _to , uint256 _value );
16+
17+ constructor () public {
18+ balances[tx .origin ] = 10000 ;
19+ }
20+
21+ function sendCoin (address receiver , uint amount ) public returns (bool sufficient ) {
22+ if (balances[msg .sender ] < amount) return false ;
23+ balances[msg .sender ] -= amount;
24+ balances[receiver] += amount;
25+ emit Transfer (msg .sender , receiver, amount);
26+ return true ;
27+ }
28+
29+ function getBalanceInEth (address addr ) public view returns (uint ){
30+ return ConvertLib.convert (getBalance (addr),2 );
31+ }
32+
33+ function getBalance (address addr ) public view returns (uint ) {
34+ return balances[addr];
35+ }
36+
37+ function test (ConvertLib.TestStruct memory testObj ) public pure {
38+ require (testObj.name > 10 );
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ pragma solidity >= 0.4.25 < 0.7.0 ;
3+
4+ contract Migrations {
5+ address public owner;
6+ uint public last_completed_migration;
7+
8+ modifier restricted () {
9+ if (msg .sender == owner) _;
10+ }
11+
12+ constructor () public {
13+ owner = msg .sender ;
14+ }
15+
16+ function setCompleted (uint completed ) public restricted {
17+ last_completed_migration = completed;
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ pragma solidity >= 0.4.25 < 0.7.0 ;
3+
4+ import "./MetaCoin.sol " ;
5+
6+ contract WrappedMetaCoin {
7+ MetaCoin public underlying;
8+
9+ constructor (MetaCoin _underlying ) public {
10+ underlying = _underlying;
11+ }
12+
13+ function sendCoin (address receiver , uint amount ) public returns (bool sufficient ) {
14+ return underlying.sendCoin (receiver, amount);
15+ }
16+
17+ function getBalanceInEth (address addr ) public view returns (uint ){
18+ return underlying.getBalanceInEth (addr);
19+ }
20+
21+ function getBalance (address addr ) public view returns (uint ) {
22+ return underlying.getBalance (addr);
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ const Migrations = artifacts . require ( "Migrations" ) ;
2+
3+ module . exports = function ( deployer ) {
4+ deployer . deploy ( Migrations ) ;
5+ } ;
Original file line number Diff line number Diff line change 1+ const ConvertLib = artifacts . require ( "ConvertLib" ) ;
2+ const MetaCoin = artifacts . require ( "MetaCoin" ) ;
3+ const WrappedMetaCoin = artifacts . require ( "WrappedMetaCoin" ) ;
4+
5+ module . exports = function ( deployer ) {
6+ deployer . deploy ( ConvertLib ) ;
7+ deployer . link ( ConvertLib , MetaCoin ) ;
8+ deployer . deploy ( MetaCoin ) . then ( ( ) => {
9+ return deployer . deploy ( WrappedMetaCoin , MetaCoin . address ) ;
10+ } ) ;
11+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " metacoin" ,
3+ "version" : " 1.0.0" ,
4+ "main" : " index.js" ,
5+ "license" : " MIT" ,
6+ "dependencies" : {
7+ "@truffle/hdwallet-provider" : " ^1.1.0" ,
8+ "dotenv" : " ^8.2.0" ,
9+ "truffle-plugin-verify" : " ../.."
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ const HDWalletProvider = require ( '@truffle/hdwallet-provider' )
2+ require ( 'dotenv' ) . config ( )
3+
4+ module . exports = {
5+ compilers : {
6+ solc : {
7+ version : '0.6.11' ,
8+ settings : {
9+ optimizer : {
10+ enabled : true ,
11+ runs : 200
12+ } ,
13+ evmVersion : 'byzantium'
14+ }
15+ }
16+ } ,
17+ plugins : [ 'truffle-plugin-verify' ] ,
18+ api_keys : {
19+ etherscan : process . env . ETHERSCAN_API_KEY
20+ } ,
21+ networks : {
22+ rinkeby : {
23+ provider : ( ) => {
24+ return new HDWalletProvider ( `${ process . env . MNEMONIC } ` , `https://rinkeby.infura.io/v3/${ process . env . INFURA_ID } ` )
25+ } ,
26+ gas : 0x7a1200 ,
27+ network_id : 4 ,
28+ skipDryRun : true
29+ } ,
30+ goerli : {
31+ provider : ( ) => {
32+ return new HDWalletProvider ( `${ process . env . MNEMONIC } ` , `https://goerli.infura.io/v3/${ process . env . INFURA_ID } ` )
33+ } ,
34+ gas : 0x7a1200 ,
35+ network_id : 5 ,
36+ skipDryRun : true
37+ }
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments