This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getWeb3Socket = (web3) => new Promise( async (resolve, reject) => { | |
try{ | |
let web3Socket = web3; | |
const networkName = await web3.eth.net.getNetworkType(); | |
if(networkName === "kovan"){ | |
web3Socket = new Web3(new Web3.providers.WebsocketProvider("wss://kovan.infura.io/ws/v3/xxx")); | |
} | |
resolve(web3Socket); | |
} | |
catch(error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "./contracts/MyToken.sol"; | |
contract MyWallet { | |
address payable private owner; | |
address private tokenAddress | |
constructor(address token) public { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
contract MyWallet { | |
address payable private owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
receive() external payable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
contract MyToken { | |
mapping (address => uint256) private _balances; | |
uint256 private _totalSupply; | |
string private _name; | |
string private _symbol; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "openzeppelin-solidity/contracts/access/Ownable.sol"; | |
contract TestContract is Ownable { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tokens can only be transferred, minted or burned if the contract is not paused | |
contract ERC20Pausable is ERC20, Pausable { | |
function _beforeTokenTransfer(address from, address to, uint256 amount) | |
internal virtual override | |
{ | |
super._beforeTokenTransfer(from, to, amount); | |
require(!paused(), "ERC20Pausable: token transfer while paused"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.5; | |
import "@openzeppelin/contracts/utils/Address.sol"; | |
contract BasicUtils { | |
using Address for address; | |
function checkIfContract(address _addr) public { | |
return _addr.isContract(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol"; | |
import "@openzeppelin/contracts/drafts/Counters.sol"; | |
contract GameItem is ERC721Full { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor() ERC721Full("GameItem", "ITM") public { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; | |
contract GLDToken is ERC20, ERC20Detailed { | |
constructor(uint256 initialSupply) ERC20Detailed("Gold", "GLD", 18) public { | |
_mint(msg.sender, initialSupply); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
/** | |
* @dev Wrappers over Solidity's uintXX casting operators with added overflow | |
* checks. | |
* | |
* Downcasting from uint256 in Solidity does not revert on overflow. This can | |
* easily result in undesired exploitation or bugs, since developers usually | |
* assume that overflows raise errors. `SafeCast` restores this intuition by |