Contracts
Get Contract ABI for Verified Contract Source Codes
Returns the contract Application Binary Interface ( ABI ) of a verified smart contract.
Find verified contracts ✅ on our Verified Contracts Source Code page.
https://api.bttcscan.com/api
?module=contract
&action=getabi
&address=0x296c2e715820aac57406c8dc8b7992c0413fda03
&apikey=YourApiKeyToken
Try this endpoint in your browser 🔗
Query Parameters
Parameter | Description |
---|---|
address | the |
Sample Response
{
"status":"1",
"message":"OK",
"result":"[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardsDistribution\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_rewardsToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stakingToken\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DepositFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"RewardAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"RewardPaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawn\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"}],\"name\":\"calcRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"changefee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"changereferalfee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"depositFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"earned\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"exit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"fee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"feeEarning\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"getFeeWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getReward\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getRewardForDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owneraddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getRewardamount\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getduration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastTimeRewardApplicable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastUpdateTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"lockaddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"lock\",\"type\":\"bool\"}],\"name\":\"lockunlockreferal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"lockaddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"lock\",\"type\":\"bool\"}],\"name\":\"lockunlockreward\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"notifyRewardAmount\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"periodFinish\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardPerToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardPerTokenStored\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardpercentage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardsDistribution\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardsDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardsToken\",\"outputs\":[{\"internalType\":\"contract ITRC20\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"referal\",\"type\":\"address\"}],\"name\":\"stake\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakeInfos\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"totalStaked\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalunstaked\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gainreward\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"referalreward\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"earnreferalreward\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"stake\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"ref\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"rewardlock\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"referallock\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stakingToken\",\"outputs\":[{\"internalType\":\"contract ITRC20\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"started\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalstakeuser\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"userRewardPerTokenPaid\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
}
A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract.
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider());
var version = web3.version.api;
$.getJSON('https://api.bttcscan.com/api?module=contract&action=getabi&address=0x0000000000000000000000000000000000001004&apikey=YourApiKeyToken', function (data) {
var contractABI = "";
contractABI = JSON.parse(data.result);
if (contractABI != '') {
var MyContract = web3.eth.contract(contractABI);
var myContractInstance = MyContract.at("0x296c2e715820aac57406c8dc8b7992c0413fda030x296c2e715820aac57406c8dc8b7992c0413fda03");
var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");
console.log("result1 : " + result);
var result = myContractInstance.members(1);
console.log("result2 : " + result);
} else {
console.log("Error");
}
});
Get Contract Source Code for Verified Contract Source Codes
Returns the Solidity source code of a verified smart contract.
📩 Tip : You can also download a CSV list of verified contracts addresses of which the code publishers have provided a corresponding Open Source license for redistribution.
https://api.bttcscan.com/api
?module=contract
&action=getsourcecode
&address=0x296c2e715820aac57406c8dc8b7992c0413fda03
&apikey=YourApiKeyToken
Try this endpoint in your browser 🔗
Query Parameters
Parameter | Description |
---|---|
address | the |
Sample Response
{
"status":"1",
"message":"OK",
"result":[
{
"SourceCode":"/*! staking.sol | SPDX-License-Identifier: MIT License */\r\n\r\npragma solidity 0.5.12;\r\n\r\n/**\r\n * @dev interface functions from the TRC20 standard.\r\n */\r\ninterface ITRC20 {\r\n /**\r\n * @dev Returns the amount of tokens in existence.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by `account`.\r\n */\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a `Transfer` event.\r\n */\r\n function transfer(address recipient, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Returns the remaining number of tokens that `spender` will be\r\n * allowed to spend on behalf of `owner` through `transferFrom`. This is\r\n * zero by default.\r\n *\r\n * This value changes when `approve` or `transferFrom` are called.\r\n */\r\n function allowance(address owner, address spender) external view returns (uint256);\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * > Beware that changing an allowance with this method brings the risk\r\n * that someone may use both the old and the new allowance by unfortunate\r\n * transaction ordering. One possible solution to mitigate this race\r\n * condition is to first reduce the spender's allowance to 0 and set the\r\n * desired value afterwards:\r\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n *\r\n * Emits an `Approval` event.\r\n */\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\r\n * allowance mechanism. `amount` is then deducted from the caller's\r\n * allowance.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a `Transfer` event.\r\n */\r\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n * another (`to`).\r\n *\r\n * Note that `value` may be zero.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n /**\r\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n * a call to `approve`. `value` is the new allowance.\r\n */\r\n event Approval(address indexed owner, address indexed spender, uint256 value);\r\n}\r\n\r\n/**\r\n * @dev Contract module which provides a basic access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * This module is used through inheritance. It will make available the modifier\r\n * `onlyOwner`, which can be aplied to your functions to restrict their use to\r\n * the owner.\r\n */\r\ncontract Ownable {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n constructor () internal {\r\n _owner = msg.sender;\r\n emit OwnershipTransferred(address(0), _owner);\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n require(isOwner(), \"Ownable: caller is not the owner\");\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Returns true if the caller is the current owner.\r\n */\r\n function isOwner() public view returns (bool) {\r\n return msg.sender == _owner;\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * > Note: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public onlyOwner {\r\n emit OwnershipTransferred(_owner, address(0));\r\n _owner = address(0);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public onlyOwner {\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n */\r\n function _transferOwnership(address newOwner) internal {\r\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n emit OwnershipTransferred(_owner, newOwner);\r\n _owner = newOwner;\r\n }\r\n}\r\n\r\n/**\r\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\r\n * checks.\r\n *\r\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\r\n * in bugs, because programmers usually assume that an overflow raises an\r\n * error, which is the standard behavior in high level programming languages.\r\n * `SafeMath` restores this intuition by reverting the transaction when an\r\n * operation overflows.\r\n *\r\n * Using this library instead of the unchecked operations eliminates an entire\r\n * class of bugs, so it's recommended to use it always.\r\n */\r\nlibrary SafeMath {\r\n /**\r\n * @dev Returns the addition of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `+` operator.\r\n *\r\n * Requirements:\r\n * - Addition cannot overflow.\r\n */\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n uint256 c = a + b;\r\n require(c >= a, \"SafeMath: addition overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n require(b <= a, \"SafeMath: subtraction overflow\");\r\n uint256 c = a - b;\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the multiplication of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `*` operator.\r\n *\r\n * Requirements:\r\n * - Multiplication cannot overflow.\r\n */\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 c = a * b;\r\n require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Solidity only automatically asserts when dividing by 0\r\n require(b > 0, \"SafeMath: division by zero\");\r\n uint256 c = a / b;\r\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n require(b != 0, \"SafeMath: modulo by zero\");\r\n return a % b;\r\n }\r\n}\r\n\r\n/**\r\n * @dev Standard math utilities missing in the Solidity language.\r\n */\r\nlibrary Math {\r\n /**\r\n * @dev Returns the largest of two numbers.\r\n */\r\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a >= b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the smallest of two numbers.\r\n */\r\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a < b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the average of two numbers. The result is rounded towards\r\n * zero.\r\n */\r\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b) / 2 can overflow, so we distribute\r\n return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\r\n }\r\n}\r\n\r\n/**\r\n * @dev Optional functions from the TRC20 standard.\r\n */\r\ncontract TRC20Detailed is ITRC20 {\r\n string private _name;\r\n string private _symbol;\r\n uint8 private _decimals;\r\n\r\n /**\r\n * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of\r\n * these values are immutable: they can only be set once during\r\n * construction.\r\n */\r\n constructor (string memory name, string memory symbol, uint8 decimals) public {\r\n _name = name;\r\n _symbol = symbol;\r\n _decimals = decimals;\r\n }\r\n\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() public view returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev Returns the symbol of the token, usually a shorter version of the\r\n * name.\r\n */\r\n function symbol() public view returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of decimals used to get its user representation.\r\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\r\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\r\n *\r\n * Tokens usually opt for a value of 18, imitating the relationship between\r\n * Ether and Wei.\r\n *\r\n * > Note that this information is only used for _display_ purposes: it in\r\n * no way affects any of the arithmetic of the contract, including\r\n * `ITRC20.balanceOf` and `ITRC20.transfer`.\r\n */\r\n function decimals() public view returns (uint8) {\r\n return _decimals;\r\n }\r\n}\r\n\r\n\r\n\r\n/**\r\n * @title SafeTRC20\r\n * @dev Wrappers around TRC20 operations that throw on failure (when the token\r\n * contract returns false). Tokens that return no value (and instead revert or\r\n * throw on failure) are also supported, non-reverting calls are assumed to be\r\n * successful.\r\n * To use this library you can add a `using SafeTRC20 for TRC20;` statement to your contract,\r\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\r\n */\r\nlibrary SafeTRC20 {\r\n using SafeMath for uint256;\r\n \r\n\r\n function safeTransfer(ITRC20 token, address to, uint256 value) internal {\r\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\r\n }\r\n\r\n function safeTransferFrom(ITRC20 token, address from, address to, uint256 value) internal {\r\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\r\n }\r\n\r\n function safeApprove(ITRC20 token, address spender, uint256 value) internal {\r\n // safeApprove should only be called when setting an initial allowance,\r\n // or when resetting it to zero. To increase and decrease it, use\r\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\r\n // solhint-disable-next-line max-line-length\r\n require((value == 0) || (token.allowance(address(this), spender) == 0),\r\n \"SafeTRC20: approve from non-zero to non-zero allowance\"\r\n );\r\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\r\n }\r\n\r\n function safeIncreaseAllowance(ITRC20 token, address spender, uint256 value) internal {\r\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\r\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\r\n }\r\n\r\n function safeDecreaseAllowance(ITRC20 token, address spender, uint256 value) internal {\r\n uint256 newAllowance = token.allowance(address(this), spender).sub(value);\r\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\r\n }\r\n\r\n /**\r\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\r\n * on the return value: the return value is optional (but if data is returned, it must not be false).\r\n * @param token The token targeted by the call.\r\n * @param data The call data (encoded using abi.encode or one of its variants).\r\n */\r\n function callOptionalReturn(ITRC20 token, bytes memory data) private {\r\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\r\n // we're implementing it ourselves.\r\n\r\n // A Solidity high level call has three parts:\r\n // 1. The target address is checked to verify it contains contract code\r\n // 2. The call itself is made, and success asserted\r\n // 3. The return value is decoded, which in turn checks the size of the returned data.\r\n // solhint-disable-next-line max-line-length\r\n require(isContract(address(token)), \"SafeTRC20: call to non-contract\");\r\n\r\n // solhint-disable-next-line avoid-low-level-calls\r\n (bool success, bytes memory returndata) = address(token).call(data);\r\n require(success, \"SafeTRC20: low-level call failed\");\r\n\r\n if (returndata.length > 0) { // Return data is optional\r\n // solhint-disable-next-line max-line-length\r\n require(abi.decode(returndata, (bool)), \"SafeTRC20: TRC20 operation did not succeed\");\r\n }\r\n \r\n \r\n }\r\n \r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies in extcodesize, which returns 0 for contracts in\r\n // construction, since the code is only stored at the end of the\r\n // constructor execution.\r\n\r\n uint256 size;\r\n // solhint-disable-next-line no-inline-assembly\r\n assembly { size := extcodesize(account) }\r\n return size > 0;\r\n }\r\n \r\n\r\n\r\n}\r\n\r\n/**\r\n * @dev Contract module that helps prevent reentrant calls to a function.\r\n *\r\n * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier\r\n * available, which can be aplied to functions to make sure there are no nested\r\n * (reentrant) calls to them.\r\n *\r\n * Note that because there is a single `nonReentrant` guard, functions marked as\r\n * `nonReentrant` may not call one another. This can be worked around by making\r\n * those functions `private`, and then adding `external` `nonReentrant` entry\r\n * points to them.\r\n */\r\ncontract ReentrancyGuard {\r\n /// @dev counter to allow mutex lock with only one SSTORE operation\r\n uint256 private _guardCounter;\r\n\r\n constructor () internal {\r\n // The counter starts at one to prevent changing it from zero to a non-zero\r\n // value, which is a more expensive operation.\r\n _guardCounter = 1;\r\n }\r\n\r\n /**\r\n * @dev Prevents a contract from calling itself, directly or indirectly.\r\n * Calling a `nonReentrant` function from another `nonReentrant`\r\n * function is not supported. It is possible to prevent this from happening\r\n * by making the `nonReentrant` function external, and make it call a\r\n * `private` function that does the actual work.\r\n */\r\n modifier nonReentrant() {\r\n _guardCounter += 1;\r\n uint256 localCounter = _guardCounter;\r\n _;\r\n require(localCounter == _guardCounter, \"ReentrancyGuard: reentrant call\");\r\n }\r\n}\r\n\r\n// Inheritance\r\ninterface IStakingRewards {\r\n // Views\r\n function lastTimeRewardApplicable() external view returns (uint256);\r\n\r\n function rewardPerToken() external view returns (uint256);\r\n\r\n function earned(address account) external view returns (uint256);\r\n\r\n function getRewardForDuration() external view returns (uint256);\r\n\r\n function totalSupply() external view returns (uint256);\r\n\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n // Mutative\r\n\r\n function stake(uint256 amount, address ref) external;\r\n\r\n function withdraw(uint256 amount) external;\r\n\r\n function getReward() external;\r\n\r\n function exit() external;\r\n}\r\n\r\ncontract RewardsDistributionRecipient {\r\n address public rewardsDistribution;\r\n\r\n function notifyRewardAmount(uint256 reward) external;\r\n\r\n modifier onlyRewardsDistribution() {\r\n require(msg.sender == rewardsDistribution, \"Caller is not RewardsDistribution contract\");\r\n _;\r\n }\r\n}\r\n\r\ncontract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard {\r\n using SafeMath for uint256;\r\n using SafeTRC20 for ITRC20;\r\n\r\n /* ========== STATE VARIABLES ========== */\r\n\r\n ITRC20 public rewardsToken;\r\n ITRC20 public stakingToken;\r\n uint256 public periodFinish = 0;\r\n uint256 public rewardRate = 0;\r\n uint256 public totalstakeuser = 0;\r\n uint256 public rewardsDuration = 30 days;\r\n uint256 public fee = 5;\r\n uint256 public rewardpercentage = 0;\r\n uint256 public feeEarning;\r\n uint256 public started;\r\n uint256 public lastUpdateTime;\r\n uint256 public rewardPerTokenStored;\r\n uint public getduration;\r\n \r\n struct stakeInfo {\r\n uint totalStaked;\r\n uint totalunstaked;\r\n uint gainreward;\r\n uint referalreward;\r\n uint earnreferalreward;\r\n bool stake;\r\n address ref;\r\n bool rewardlock;\r\n bool referallock;\r\n }\r\n\r\n mapping(address => uint256) public userRewardPerTokenPaid;\r\n mapping(address => uint256) public rewards;\r\n mapping(address => uint) public depositFee;\r\n\r\n uint256 private _totalSupply;\r\n mapping(address => uint256) private _balances;\r\n mapping(address => uint256) private _totalstaked;\r\n mapping (address => stakeInfo) public stakeInfos;\r\n \r\n\r\n /* ========== CONSTRUCTOR ========== */\r\n\r\n constructor(\r\n address _rewardsDistribution,\r\n address _rewardsToken,\r\n address _stakingToken\r\n ) public {\r\n rewardsToken = ITRC20(_rewardsToken);\r\n stakingToken = ITRC20(_stakingToken);\r\n rewardsDistribution = _rewardsDistribution;\r\n \r\n stakeInfo memory StakeInfo;\r\n StakeInfo = stakeInfo({\r\n stake:true,\r\n totalStaked: 0,\r\n totalunstaked:0,\r\n gainreward:0,\r\n referalreward:0,\r\n earnreferalreward:0,\r\n ref:address(0),\r\n rewardlock:false,\r\n referallock:false\r\n });\r\n stakeInfos[_rewardsDistribution] = StakeInfo; \r\n \r\n }\r\n\r\n /* ========== VIEWS ========== */\r\n\r\n function totalSupply() external view returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n function balanceOf(address account) external view returns (uint256) {\r\n return _balances[account];\r\n }\r\n\r\n function lastTimeRewardApplicable() public view returns (uint256) {\r\n return Math.min(block.timestamp, periodFinish);\r\n }\r\n\r\n function rewardPerToken() public view returns (uint256) {\r\n if (_totalSupply == 0) {\r\n return rewardPerTokenStored;\r\n }\r\n \r\n return\r\n rewardPerTokenStored.add(\r\n lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)\r\n );\r\n }\r\n function calcRate(uint totalSupply) external view returns(uint256) {\r\n \r\n return\r\n rewardPerTokenStored.add(\r\n lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(totalSupply)\r\n );\r\n }\r\n\r\n function earned(address account) public view returns (uint256) {\r\n //eee = 1;\r\n return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);\r\n }\r\n\r\n function getRewardForDuration() external view returns (uint256) {\r\n return rewardRate.mul(rewardsDuration);\r\n }\r\n\r\n /* ========== MUTATIVE FUNCTIONS ========== */\r\n function stake(uint256 amount , address referal) external nonReentrant updateReward(msg.sender) {\r\n require(amount > 0, \"Cannot stake 0\");\r\n uint deposit_fee = amount.mul(fee)/100;\r\n depositFee[rewardsDistribution]+=deposit_fee;\r\n amount = amount.sub(deposit_fee);\r\n _totalSupply = _totalSupply.add(amount);\r\n _balances[msg.sender] = _balances[msg.sender].add(amount);\r\n \r\n stakingToken.safeTransferFrom(msg.sender, address(this), amount.add(deposit_fee));\r\n if(stakeInfos[msg.sender].stake == true){\r\n stakeInfos[msg.sender].totalStaked +=amount;\r\n totalstakeuser++;\r\n }else{\r\n stakeInfo memory StakeInfo;\r\n StakeInfo = stakeInfo({\r\n stake:true,\r\n totalStaked: stakeInfos[msg.sender].totalStaked.add(amount),\r\n totalunstaked:0,\r\n gainreward:0,\r\n referalreward:0,\r\n earnreferalreward:0,\r\n ref:referal,\r\n rewardlock:false,\r\n referallock:false\r\n });\r\n stakeInfos[msg.sender] = StakeInfo; \r\n }\r\n emit Staked(msg.sender, amount);\r\n emit DepositFee(address(0), deposit_fee);\r\n }\r\n\r\n function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) {\r\n require(amount > 0, \"Cannot withdraw 0\");\r\n _totalSupply = _totalSupply.sub(amount);\r\n _balances[msg.sender] = _balances[msg.sender].sub(amount);\r\n stakingToken.safeTransfer(msg.sender, amount);\r\n stakeInfos[msg.sender].totalunstaked +=amount;\r\n emit Withdrawn(msg.sender, amount);\r\n }\r\n\r\n function getReward() public nonReentrant updateReward(msg.sender) {\r\n uint256 reward = rewards[msg.sender];\r\n if (reward > 0 && stakeInfos[msg.sender].rewardlock==false) {\r\n rewards[msg.sender] = 0;\r\n uint rewardamt = reward.mul(rewardpercentage)/100;\r\n uint amount = reward.sub(rewardamt);\r\n rewardsToken.safeTransfer(msg.sender, amount);\r\n address refaddr =stakeInfos[msg.sender].ref;\r\n if(refaddr!=address(0)){\r\n rewardsToken.safeTransfer(refaddr, rewardamt);\r\n stakeInfos[refaddr].earnreferalreward+=rewardamt;\r\n }else{\r\n rewardsToken.safeTransfer(rewardsDistribution, rewardamt);\r\n stakeInfos[rewardsDistribution].earnreferalreward+=rewardamt;\r\n }\r\n stakeInfos[msg.sender].gainreward +=amount;\r\n emit RewardPaid(msg.sender, reward);\r\n }\r\n }\r\n \r\n function exit() external {\r\n withdraw(_balances[msg.sender]);\r\n getReward();\r\n }\r\n \r\n function lockunlockreward(address lockaddress, bool lock) external onlyRewardsDistribution() {\r\n stakeInfos[lockaddress].rewardlock =lock;\r\n }\r\n function lockunlockreferal(address lockaddress, bool lock) external onlyRewardsDistribution() {\r\n stakeInfos[lockaddress].referallock =lock;\r\n }\r\n function changefee(uint256 amount) external onlyRewardsDistribution() {\r\n fee =amount;\r\n }\r\n function changereferalfee(uint256 amount) external onlyRewardsDistribution() {\r\n rewardpercentage =amount;\r\n }\r\n\r\n /* ========== RESTRICTED FUNCTIONS ========== */\r\n\r\n function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) {\r\n \r\n if (block.timestamp >= periodFinish) {\r\n \r\n rewardRate = reward.div(rewardsDuration);\r\n \r\n } else {\r\n uint256 remaining = periodFinish.sub(block.timestamp);\r\n uint256 leftover = remaining.mul(rewardRate);\r\n rewardRate = reward.add(leftover).div(rewardsDuration);\r\n }\r\n\r\n // Ensure the provided reward amount is not more than the balance in the contract.\r\n // This keeps the reward rate in the right range, preventing overflows due to\r\n // very high values of rewardRate in the earned and rewardsPerToken functions;\r\n // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.\r\n uint balance = rewardsToken.balanceOf(address(this));\r\n require(rewardRate <= balance.div(rewardsDuration), \"Provided reward too high\");\r\n uint256 blocktime= block.timestamp;\r\n lastUpdateTime =blocktime;\r\n periodFinish = block.timestamp.add(rewardsDuration);\r\n emit RewardAdded(reward);\r\n }\r\n \r\n function getRewardamount(address owneraddr, uint amount) external onlyRewardsDistribution updateReward(address(0)) {\r\n rewardsToken.safeTransfer(owneraddr,amount);\r\n }\r\n \r\n function getFeeWithdrawal(address _owner) external onlyRewardsDistribution {\r\n uint feeamount = depositFee[msg.sender];\r\n stakingToken.safeTransfer(msg.sender, feeamount);\r\n feeEarning +=feeamount;\r\n depositFee[msg.sender]=0;\r\n emit FeeWithdrawal(msg.sender,feeamount);\r\n }\r\n\r\n /* ========== MODIFIERS ========== */\r\n\r\n modifier updateReward(address account) {\r\n rewardPerTokenStored = rewardPerToken();\r\n lastUpdateTime = lastTimeRewardApplicable();\r\n if (account != address(0)) {\r\n rewards[account] = earned(account);\r\n userRewardPerTokenPaid[account] = rewardPerTokenStored;\r\n }\r\n _;\r\n }\r\n\r\n /* ========== EVENTS ========== */\r\n\r\n event RewardAdded(uint256 reward);\r\n event Staked(address indexed user, uint256 amount);\r\n event Withdrawn(address indexed user, uint256 amount);\r\n event RewardPaid(address indexed user, uint256 reward);\r\n event DepositFee(address indexed user, uint256 amount);\r\n event FeeWithdrawal(address indexed user, uint256 amount);\r\n}\r\n\r\ninterface IStakingV2TRC20 {\r\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\r\n}\r\n\r\ncontract StakingRewardsFactory is Ownable {\r\n // immutables\r\n address public rewardsToken;\r\n uint public stakingRewardsGenesis;\r\n uint PERIOD_LENGTH = 365 days;\r\n uint PERIOD_LENGTH1 = 500 days;\r\n uint public cccccc;\r\n uint public cccccc1;\r\n\r\n // the staking tokens for which the rewards contract has been deployed\r\n address[] public stakingTokens;\r\n\r\n // info about rewards for a particular staking token\r\n struct StakingRewardsInfo {\r\n address stakingRewards;\r\n uint rewardAmount;\r\n }\r\n\r\n // rewards info by staking token\r\n mapping(address => StakingRewardsInfo) public stakingRewardsInfoByStakingToken;\r\n\r\n constructor(\r\n address _rewardsToken,\r\n uint _stakingRewardsGenesis\r\n ) Ownable() public {\r\n require(_stakingRewardsGenesis >= block.timestamp, 'StakingRewardsFactory::constructor: genesis too soon');\r\n\r\n rewardsToken = _rewardsToken;\r\n stakingRewardsGenesis = _stakingRewardsGenesis;\r\n cccccc =block.timestamp+PERIOD_LENGTH;\r\n cccccc1 = now+PERIOD_LENGTH1;\r\n }\r\n\r\n ///// permissioned functions\r\n\r\n // deploy a staking reward contract for the staking token, and store the reward amount\r\n // the reward will be distributed to the staking reward contract no sooner than the genesis\r\n // staking fee must pass in wei format\r\n function deploy(address stakingToken, uint rewardAmount) public onlyOwner {\r\n StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];\r\n require(info.stakingRewards == address(0), 'StakingRewardsFactory::deploy: already deployed');\r\n\r\n info.stakingRewards = address(new StakingRewards(/*_rewardsDistribution=*/ address(this), rewardsToken, stakingToken));\r\n info.rewardAmount = rewardAmount;\r\n stakingTokens.push(stakingToken);\r\n }\r\n\r\n ///// permissionless functions\r\n\r\n\r\n // notify reward amount for an individual staking token.\r\n // this is a fallback in case the notifyRewardAmounts costs too much gas to call for all contracts\r\n function notifyRewardAmount(address stakingToken,uint amount) public {\r\n require(block.timestamp >= stakingRewardsGenesis, 'StakingRewardsFactory::notifyRewardAmount: not ready');\r\n\r\n StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];\r\n require(info.stakingRewards != address(0), 'StakingRewardsFactory::notifyRewardAmount: not deployed');\r\n uint rewardAmount;\r\n if (info.rewardAmount > 0) {\r\n rewardAmount = info.rewardAmount;\r\n info.rewardAmount = 0;\r\n }else{\r\n rewardAmount = amount;\r\n }\r\n\r\n require(\r\n ITRC20(rewardsToken).transferFrom(msg.sender,info.stakingRewards, rewardAmount),\r\n 'StakingRewardsFactory::notifyRewardAmount: transfer failed'\r\n );\r\n StakingRewards(info.stakingRewards).notifyRewardAmount(rewardAmount);\r\n \r\n }\r\n \r\n function faileSafe(address stakingToken, uint amount) public onlyOwner {\r\n StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];\r\n StakingRewards(info.stakingRewards).getRewardamount(msg.sender,amount);\r\n }\r\n \r\n function getFeeWithdrawal(address stakingToken) public onlyOwner {\r\n StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];\r\n StakingRewards(info.stakingRewards).getFeeWithdrawal(msg.sender);\r\n }\r\n}",
"ABI":"[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardsDistribution\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_rewardsToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stakingToken\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DepositFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"RewardAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"RewardPaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawn\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"}],\"name\":\"calcRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"changefee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"changereferalfee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"depositFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"earned\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"exit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"fee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"feeEarning\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"getFeeWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getReward\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getRewardForDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owneraddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getRewardamount\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getduration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastTimeRewardApplicable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastUpdateTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"lockaddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"lock\",\"type\":\"bool\"}],\"name\":\"lockunlockreferal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"lockaddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"lock\",\"type\":\"bool\"}],\"name\":\"lockunlockreward\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"notifyRewardAmount\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"periodFinish\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardPerToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardPerTokenStored\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardpercentage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardsDistribution\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardsDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"rewardsToken\",\"outputs\":[{\"internalType\":\"contract ITRC20\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"referal\",\"type\":\"address\"}],\"name\":\"stake\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakeInfos\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"totalStaked\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalunstaked\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gainreward\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"referalreward\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"earnreferalreward\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"stake\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"ref\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"rewardlock\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"referallock\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stakingToken\",\"outputs\":[{\"internalType\":\"contract ITRC20\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"started\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalstakeuser\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"userRewardPerTokenPaid\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
"ContractName":"StakingRewards",
"CompilerVersion":"v0.5.12+commit.7709ece9",
"OptimizationUsed":"1",
"Runs":"200",
"ConstructorArguments":"00000000000000000000000028e91d93bb30ab309d2a43f2f0f48c9b89e564f60000000000000000000000000445f72e4dcade5e8f25266373f0f901890041bf000000000000000000000000f382c85daf5283dd6d5f5719a88d728fa9d81a18",
"EVMVersion":"Default",
"Library":"",
"LicenseType":"MIT",
"Proxy":"0",
"Implementation":"",
"SwarmSource":"bzzr://4d0842f7536c30051190e02aec0e8c71aff1f3f7201dca7af1333d6745950250"
}
]
}
Get Contract Creator and Creation Tx Hash
Returns a contract's deployer address and transaction hash it was created, up to 5 at a time.
https://api.bttcscan.com/api
?module=contract
&action=getcontractcreation
&contractaddresses=0xa8c87a4b2de9bcebeadcc1ca4e6331fe28e3a378,0xe9e7cea3dedca5984780bafc599bd69add087d56,0xe4462eb568E2DFbb5b0cA2D3DbB1A35C9Aa98aad,0x10ed43c718714eb63d5aa57b78b54704e256024e,0x10e66c37b81858cf8377f766b6dfb5af6700a73c
&apikey=YourApiKeyToken
Try this endpoint in your browser 🔗
Query Parameters
Parameter | Description |
---|---|
contractaddresses | the |
Sample Response
{
"status": "1",
"message": "OK",
"result": [
{
"contractAddress": "0x10e66c37b81858cf8377f766b6dfb5af6700a73c",
"contractCreator": "0x187549f02d96d94945f2c4dd206cf58aeed8ebae",
"txHash": "0x372eaf2d68524ebb0b5ec5b815983df2bcc29c9516a30116eb2bf02aae250c5e"
},
{
"contractAddress": "0x10ed43c718714eb63d5aa57b78b54704e256024e",
"contractCreator": "0xdb6f5fb9311ae8885620ee893887c3d85c8293d6",
"txHash": "0x1bfbff8411ed44e609d911476b0d35a28284545b690902806ea0a7ff0453e931"
},
{
"contractAddress": "0xa8c87a4b2de9bcebeadcc1ca4e6331fe28e3a378",
"contractCreator": "0xd71110b333c547eb9139bef719d7ab4513107588",
"txHash": "0xdd94fbce146d67c70ab6aea7fd0807706d1e1867ed67cc1b236516e6ba23c6f6"
},
{
"contractAddress": "0xe9e7cea3dedca5984780bafc599bd69add087d56",
"contractCreator": "0xf07c30e4cd6cfff525791b4b601bd345bded7f47",
"txHash": "0x0f01fc521030f178115c880e200b09a40c9510f49de227aa880276f92670a3d6"
}
]
}
Verify Source Code
Submits a contract source code to BTTCScan for verification.
See Demo Source Verification Submission Code at Source Code Verification Sample.
Requires a valid BTTCScan API key, it will be rejected otherwise
Current daily limit of 100 submissions per day per user (subject to change)
Only supports HTTP POST due to max transfer size limitations for HTTP GET
Supports up to 10 different library pairs
Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files.
List of supported solc versions, only solc version v0.4.11 and above is supported e.g. v0.4.25+commit.59dbf8f1
Upon successful submission you will receive a GUID (50 characters) as a receipt
You may use this GUID to track the status of your submission
Verified Source Codes will be displayed at the Verified Contracts page.
Source Code Submission Gist
👇 Note: Upon successful submission, a GUID is returned, which can be used to check for submission status.
//Submit Source Code for Verification
$.ajax({
type: "POST", //Only POST supported
url: "//api.bttcscan.com/api", //Set to the correct API url for Other Networks
data: {
apikey: $('#apikey').val(), //A valid API-Key is required
module: 'contract', //Do not change
action: 'verifysourcecode', //Do not change
contractaddress: $('#contractaddress').val(), //Contract Address starts with 0x...
sourceCode: $('#sourceCode').val(), //Contract Source Code (Flattened if necessary)
codeformat: $('#codeformat').val(), //solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support
contractname: $('#contractname').val(), //ContractName (if codeformat=solidity-standard-json-input, then enter contractname as ex: erc20.sol:erc20)
compilerversion: $('#compilerversion').val(), // see https://bttcscan.com/solcversions for list of support versions
optimizationUsed: $('#optimizationUsed').val(), //0 = No Optimization, 1 = Optimization used (applicable when codeformat=solidity-single-file)
runs: 200, //set to 200 as default unless otherwise (applicable when codeformat=solidity-single-file)
constructorArguements: $('#constructorArguements').val(), //if applicable
evmversion: $('#evmVersion').val(), //leave blank for compiler default, homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul (applicable when codeformat=solidity-single-file)
licenseType: $('#licenseType').val(), //Valid codes 1-12 where 1=No License .. 12=Apache 2.0, see https://bttcscan.com/contract-license-types
libraryname1: $('#libraryname1').val(), //if applicable, a matching pair with libraryaddress1 required
libraryaddress1: $('#libraryaddress1').val(), //if applicable, a matching pair with libraryname1 required
libraryname2: $('#libraryname2').val(), //if applicable, matching pair required
libraryaddress2: $('#libraryaddress2').val(), //if applicable, matching pair required
libraryname3: $('#libraryname3').val(), //if applicable, matching pair required
libraryaddress3: $('#libraryaddress3').val(), //if applicable, matching pair required
libraryname4: $('#libraryname4').val(), //if applicable, matching pair required
libraryaddress4: $('#libraryaddress4').val(), //if applicable, matching pair required
libraryname5: $('#libraryname5').val(), //if applicable, matching pair required
libraryaddress5: $('#libraryaddress5').val(), //if applicable, matching pair required
libraryname6: $('#libraryname6').val(), //if applicable, matching pair required
libraryaddress6: $('#libraryaddress6').val(), //if applicable, matching pair required
libraryname7: $('#libraryname7').val(), //if applicable, matching pair required
libraryaddress7: $('#libraryaddress7').val(), //if applicable, matching pair required
libraryname8: $('#libraryname8').val(), //if applicable, matching pair required
libraryaddress8: $('#libraryaddress8').val(), //if applicable, matching pair required
libraryname9: $('#libraryname9').val(), //if applicable, matching pair required
libraryaddress9: $('#libraryaddress9').val(), //if applicable, matching pair required
libraryname10: $('#libraryname10').val(), //if applicable, matching pair required
libraryaddress10: $('#libraryaddress10').val() //if applicable, matching pair required
},
success: function (result) {
console.log(result);
if (result.status == "1") {
//1 = submission success, use the guid returned (result.result) to check the status of your submission.
// Average time of processing is 30-60 seconds
document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;
// result.result is the GUID receipt for the submission, you can use this guid for checking the verification status
} else {
//0 = error
document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;
}
console.log("status : " + result.status);
console.log("result : " + result.result);
},
error: function (result) {
console.log("error!");
document.getElementById("postresult").innerHTML = "Unexpected Error"
}
});
Check Source Code Verification Submission Status
//Check Source Code Verification Status
$.ajax({
type: "GET",
url: "//api.bttcscan.com/api",
data: {
apikey: $('#apikey').val(),
guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above
module: "contract",
action: "checkverifystatus"
},
success: function (result) {
console.log("status : " + result.status); //0=Error, 1=Pass
console.log("message : " + result.message); //OK, NOTOK
console.log("result : " + result.result); //result explanation
$('#guidstatus').html(">> " + result.result);
},
error: function (result) {
alert('error');
}
});
Verify Proxy Contract
Submits a proxy contract source code to Etherscan for verification.
Requires a valid BTTCScan API key, it will be rejected otherwise
Current daily limit of 100 submissions per day per user (subject to change)
Only supports HTTP post
Upon successful submission you will receive a GUID (50 characters) as a receipt
You may use this GUID to track the status of your submission
Verified proxy contracts will display the "Read/Write as Proxy" of the implementation contract under the contract address's contract tab
Verifying Proxy Contract using cURL
// example with only the mandatory contract address parameter
curl -d "address=0xcbdcd3815b5f975e1a2c944a9b2cd1c985a1cb7f" "https://api.bttcscan.com/api?module=contract&action=verifyproxycontract&apikey=YourApiKeyToken"
// example using the expectedimplementation optional parameter
// the expectedimplementation enforces a check to ensure the returned implementation contract address == address picked up by the verifier
curl -d "address=0xbc46363a7669f6e12353fa95bb067aead3675c29&expectedimplementation=0xe45a5176bc0f2c1198e2451c4e4501d4ed9b65a6" "https://api.bttcscan.com/api?module=contract&action=verifyproxycontract&apikey=YourApiKeyToken"
// OK
{"status":"1","message":"OK","result":"gwgrrnfy56zf6vc1fljuejwg6pelnc5yns6fg6y2i6zfpgzquz"}
// NOTOK
{"status":"0","message":"NOTOK","result":"Invalid API Key"}
Checking Proxy Contract Verification Submission Status using cURL
curl "https://api.bttcscan.com/api?module=contract&action=checkproxyverification&guid=gwgrrnfy56zf6vc1fljuejwg6pelnc5yns6fg6y2i6zfpgzquz&apikey=YourApiKeyToken"
// OK
{"status":"1","message":"OK","result":"The proxy's (0xbc46363a7669f6e12353fa95bb067aead3675c29) implementation contract is found at 0xe45a5176bc0f2c1198e2451c4e4501d4ed9b65a6 and is successfully updated."}
// NOTOK
{"status":"0","message":"NOTOK","result":"A corresponding implementation contract was unfortunately not detected for the proxy address."}
Last updated