Bootstrap
Bootstrap
Karma EVM Blockchain
Dashboard
Blocks
Transactions
Pending txs
Addresses
Tokens
Deploy contract
Connect wallet
Deploy
txValue:
KARMA
/* Name: TEST Token Version: 0.0.1 */ // set your token details at the end of the contract code class Ownable { owner = '0x0000000000000000000000000000000000000000'; OwnershipTransferred(oldOwner, newOwner) {} // event constructor() { this.owner = msg.sender; } getOwner() { return [this.owner]; } transferOwnership(newOwner) { require(newOwner != address(0), "Ownable: new owner is the zero address"); this._transferOwnership(newOwner); } _transferOwnership(newOwner) { newOwner = newOwner.toLowerCase(); const oldOwner = this.owner; this.owner = newOwner; emit('OwnershipTransferred', [oldOwner, newOwner]); } _onlyOwner(next) { require(msg.sender.toLowerCase() == this.owner, 'only owner can execute this'); next(); } } // Methods Ownable.prototype.OwnershipTransferred.event = true; Ownable.prototype.OwnershipTransferred.inputs = ['address indexed', 'address indexed']; // Methods Ownable.prototype.getOwner.view = true; Ownable.prototype.getOwner.outputs = ['address']; Ownable.prototype.transferOwnership.inputs = ['address']; Ownable.prototype.transferOwnership.modifiers = ['_onlyOwner']; Ownable.prototype._transferOwnership.internal = true; Ownable.prototype._onlyOwner.internal = true; class ERC20Token extends Ownable { name = 'ERC20 Token'; symbol = 'ERC20'; decimals = 18; totalSupply = number('0'); allowed = {}; balances = {}; supportedInterfaces = { '0x36372b07': true, // ERC20 '0x06fdde03': true, // ERC20 name '0x95d89b41': true, // ERC20 symbol '0x313ce567': true, // ERC20 decimals }; Transfer(sender, recipient, amount) {} // event Approval(owner, spender, amount) {} // event Mint(minter, amount) {} // event Burn(burner, amount) {} // event balanceOf(holderAddress) { holderAddress = holderAddress.toLowerCase(); var tokenBalances = this.balances || {}; if (holderAddress in tokenBalances) { const balance = tokenBalances[holderAddress]; return [balance]; } return [number(0)]; } transfer(recipient, amount) { recipient = recipient.toLowerCase(); const sender = msg.sender; var tokenBalances = this.balances || {}; if (! (sender in tokenBalances)) { _throw('INSUFFICIENT_TOKEN_BALANCE'); } if (tokenBalances[sender].lt(amount)) { _throw('INSUFFICIENT_TOKEN_BALANCE'); } if (this._decrementUserBalance.bind(this)(sender, amount)) { this._incrementUserBalance.bind(this)(recipient, amount) } emit('Transfer', [sender, recipient, amount]); return [true]; } transferFrom(sender, recipient, amount) { sender = sender.toLowerCase(); recipient = recipient.toLowerCase(); var tokenBalances = this.balances || {}; var tokenAllowances = this.allowed || {}; require(sender in tokenBalances, 'MISSING_TOKEN_BALANCE'); if (tokenBalances[sender].lt(amount)) { _throw('INSUFFICIENT_TOKEN_BALANCE'); } require(sender == msg.sender || (sender in tokenAllowances && msg.sender in tokenAllowances[sender]), "MISSING_ALLOWANCE"); if (sender != msg.sender && tokenAllowances[sender][msg.sender].lt(amount)) { _throw('INSUFFICIENT_TOKEN_ALLOWANCE'); } tokenAllowances[sender][msg.sender] = tokenAllowances[sender][msg.sender].sub(amount); if (this._decrementUserBalance.bind(this)(sender, amount)) { this._incrementUserBalance.bind(this)(recipient, amount) } emit('Transfer', [sender, recipient, amount]); return [true]; } allowance(owner, spender) { owner = owner.toLowerCase(); spender = spender.toLowerCase(); var tokenAllowances = this.allowed || {}; if (owner in tokenAllowances && spender in tokenAllowances[owner]) { return [tokenAllowances[owner][spender]]; } return [number(0)]; } approve(spender, value) { spender = spender.toLowerCase(); var tokenAllowances = this.allowed || {}; if (! (msg.sender in tokenAllowances)) { tokenAllowances[msg.sender] = {}; } tokenAllowances[msg.sender][spender] = value; emit('Approval', [msg.sender, spender, value]); return [true]; } mint(userAddress, amount) { this._mint(userAddress, amount); } _mint(userAddress, amount) { userAddress = userAddress.toLowerCase(); if (userAddress == address(0).address) { _throw('ERC20: mint to the zero address'); } if (this._incrementUserBalance.bind(this)(userAddress, amount)) { this.totalSupply = this.totalSupply.add(amount); } emit('Mint', [userAddress, amount]); } burn(userAddress, amount) { this._burn(userAddress, amount); } _burn(userAddress, amount) { userAddress = userAddress.toLowerCase(); if (userAddress == address(0).address) { _throw('ERC20: burn from the zero address'); } if (this._decrementUserBalance.bind(this)(userAddress, amount)) { this.totalSupply = this.totalSupply.sub(amount); } emit('Burn', [userAddress, amount]); } supportsInterface(interfaceID) { const _interfaces = this.supportedInterfaces || {}; return [ ((interfaceID in _interfaces) ? _interfaces[interfaceID] : false) ]; } _decrementUserBalance(holderAddress, amount) { var tokenBalances = this.balances || {}; if (! (holderAddress in tokenBalances)) { _throw('INSUFFICIENT_TOKEN_BALANCE'); } if (amount.gt(tokenBalances[holderAddress])) { _throw('INSUFFICIENT_TOKEN_BALANCE'); } tokenBalances[holderAddress] = tokenBalances[holderAddress].sub(amount); return true; } _incrementUserBalance(holderAddress, amount) { var tokenBalances = this.balances || {}; if (! (holderAddress in tokenBalances)) { tokenBalances[holderAddress] = number(0); } tokenBalances[holderAddress] = tokenBalances[holderAddress].add(amount); return true; } } // Events ERC20Token.prototype.Transfer.event = true; ERC20Token.prototype.Transfer.inputs = ['address indexed', 'address indexed', 'uint256']; ERC20Token.prototype.Approval.event = true; ERC20Token.prototype.Approval.inputs = ['address indexed', 'address indexed', 'uint256']; ERC20Token.prototype.Mint.event = true; ERC20Token.prototype.Mint.inputs = ['address indexed', 'uint256']; ERC20Token.prototype.Burn.event = true; ERC20Token.prototype.Burn.inputs = ['address indexed', 'uint256']; // Methods ERC20Token.prototype.balanceOf.view = true; ERC20Token.prototype.balanceOf.inputs = ['address']; ERC20Token.prototype.balanceOf.outputs = ['uint256']; ERC20Token.prototype.transfer.inputs = ['address', 'uint256']; ERC20Token.prototype.transfer.outputs = ['bool']; ERC20Token.prototype.transferFrom.inputs = ['address', 'address', 'uint256']; ERC20Token.prototype.transferFrom.outputs = ['bool']; ERC20Token.prototype.allowance.view = true; ERC20Token.prototype.allowance.inputs = ['address', 'address']; ERC20Token.prototype.allowance.outputs = ['uint256']; ERC20Token.prototype.approve.inputs = ['address', 'uint256']; ERC20Token.prototype.approve.outputs = ['bool']; ERC20Token.prototype.mint.inputs = ['address', 'uint256']; ERC20Token.prototype.mint.modifiers = ['_onlyOwner']; ERC20Token.prototype._mint.internal = true; ERC20Token.prototype.burn.inputs = ['address', 'uint256']; ERC20Token.prototype.burn.modifiers = ['_onlyOwner']; ERC20Token.prototype._burn.internal = true; ERC20Token.prototype.supportsInterface.view = true; ERC20Token.prototype.supportsInterface.inputs = ['bytes4']; ERC20Token.prototype.supportsInterface.outputs = ['bool']; ERC20Token.prototype._decrementUserBalance.internal = true; ERC20Token.prototype._incrementUserBalance.internal = true; class TestToken extends ERC20Token { name = 'TEST Token'; symbol = 'TEST'; decimals = 18; test = ""; constructor(test) { super(); this.totalSupply = number('100000000' + '000000000000000000'); // 100 000 000 TEST this.balances[msg.sender] = this.totalSupply; this.test = test; } } return TestToken;
Constructor parameters :
Parameter %IDX%