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
| contract('ExampleToken', accounts => { | |
| beforeEach(async function() { | |
| this.owner = accounts[0] | |
| this.token = await ExampleToken.new() | |
| }) | |
| it('all values should be set on constructor call', async function() { | |
| const totalSupply = await this.token.totalSupply(); | |
| assert.equal(1000, totalSupply.valueOf(), "correct total supply should be set") |
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
| describe('transfer', function () { | |
| const this.to = accounts[4] | |
| const amount = 100 | |
| it('transfers the requested amount', async function () { | |
| await this.token.transfer(this.to, amount, { from: this.owner }) | |
| const senderBalance = await this.token.balanceOf(this.owner) | |
| assert.equal(senderBalance, 0); |
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
| describe('transfer from', function () { | |
| beforeEach(async function () { | |
| await this.token.approve(this.spender, 99, { from: this.owner }); | |
| }); | |
| describe('when the owner has enough balance', function () { | |
| const amount = 100; | |
| it('reverts', async function () { |
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
| describe('approve', function () { | |
| const amount = 100; | |
| it('approves the requested amount', async function () { | |
| await this.token.approve(this.to, amount, { from: this.owner }); | |
| const allowance = await this.token.allowance(this.owner, this.to); | |
| assert.equal(allowance, amount); | |
| }); | |
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
| function burn() public onlyAdmin { | |
| extraTokensAmount = balances[tokenHolder]; | |
| _totalSupply = _totalSupply.sub(extraTokensAmount); | |
| balances[tokenHolder] = 0; | |
| emit Burn(tokenHolder, extraTokensAmount); | |
| } |
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
| using System; | |
| using System.IO; | |
| using System.Linq; | |
| using Neo; | |
| using Neo.VM; | |
| using Neo.Cryptography; | |
| namespace ConsoleApplication1 | |
| { | |
| class program |
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
| function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) { | |
| uint cnt = _receivers.length; | |
| uint256 amount = uint256(cnt) * _value; | |
| require(cnt > 0 && cnt <= 20); | |
| require(_value > 0 && balances[msg.sender] >= amount); | |
| balances[msg.sender] = balances[msg.sender].sub(amount); | |
| for (uint i = 0; i < cnt; i++) { | |
| balances[_receivers[i]] = balances[_receivers[i]].add(_value); | |
| Transfer(msg.sender, _receivers[i], _value); |
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
| function _forceTransfer(address _from, address _to, uint256 _value) internal returns (bool) { | |
| require(_value <= _balances[_from]); | |
| require(_to != address(0)); | |
| _balances[_from] = _balances[_from].sub(_value); | |
| _balances[_to] = _balances[to].add(_value); | |
| emit Transfer(_from, _to, _value); | |
| return true; | |
| } |
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
| import datetime | |
| import hashlib | |
| import time | |
| class Message: | |
| def __init__(self, data): | |
| self.hash = None | |
| self.prev_hash = None | |
| self.timestamp = time.time() | |
| self.size = len(data.encode('utf-8')) |
OlderNewer