hq20 / stakingtoken Goto Github PK
View Code? Open in Web Editor NEWImplements a basic staking token with incentive distribution.
License: Apache License 2.0
Implements a basic staking token with incentive distribution.
License: Apache License 2.0
I think the addStakeholder and removeStakeholder should be internal functions rather than public, as they are only created for the other fucntions in the contract to use them.
Would it be better to transfer the _stake amount to contract address itself instead of burn in createStake() ?
https://github.com/HQ20/StakingToken/blob/master/contracts/StakingToken.sol#L50
_burn subtracts the totalSupply and hence the suggestion.
Similarly for removeStake(), transfer back the amount from contract address to the msg.sender
Example:
mapping(address => uint256) public staked;
function stake(uint256 amount) external {
require(balanceOf(msg.sender) >= amount, "staking amount is more than balance");
transfer(address(this), amount);
staked[msg.sender] += amount;
}
function unstake(uint256 amount) external {
require(staked[msg.sender] >= amount, "staked amount is less than withdrawl amount");
staked[msg.sender] -= amount;
_transfer(address(this), msg.sender, amount);
}
Hi did you tested the code before deploy and what about code audit?
I see that the array will be searched every time-
Is the position of the items inside the array different every time the contract get loaded into an client?
If the position is fixed then maybe a more processor time friendly logic could be implemented.
I've very low amount of coding knowledge. Can you help me by telling how to make stakeable erc20 token with remix. I don't find any options to add name, symbol, decimals & supply.
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file.
I have 1 custom token on Kovan test net, but it just a simple smartcontact like "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol". And now I want to update Staking for my token. Can I do that without create 1 new token?
SyntaxError: Invalid pragma "^"
pragma ^solidity 0.5.0;
https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.