Created
May 12, 2021 18:14
-
-
Save pi0neerpat/474717b2e7866b278a37b2ee4f158d3e to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.7.6+commit.7338295f.js&optimize=false&runs=200&gist=
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.7.0; | |
import {ERC20} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0-solc-0.7/contracts/token/ERC20/ERC20.sol"; | |
contract GRT is ERC20 { | |
constructor () | |
ERC20 ("Graph token", "GRT") | |
{ | |
_mint(msg.sender, 100e18); | |
} | |
} |
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.7.0; | |
import {IERC20} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0-solc-0.7/contracts/token/ERC20/IERC20.sol"; | |
contract Staking { | |
IERC20 token; | |
mapping(address => uint256) indexerDelegation; | |
constructor (IERC20 _token) { | |
token = _token; | |
} | |
function delegate(address _indexer, uint256 _tokens) | |
external | |
returns (uint256) | |
{ | |
address delegator = msg.sender; | |
// Transfer tokens to delegate to this contract | |
token.transferFrom(delegator, address(this), _tokens); | |
indexerDelegation[_indexer] += _tokens; | |
return _tokens; | |
} | |
function getDelegation(address _indexer) public view returns (uint256){ | |
return indexerDelegation[_indexer]; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment