Skip to content

Instantly share code, notes, and snippets.

View MrCrambo's full-sized avatar
🏓
Win the world

mrcrambo MrCrambo

🏓
Win the world
  • Russia
View GitHub Profile
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")
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);
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 () {
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);
});
function burn() public onlyAdmin {
extraTokensAmount = balances[tokenHolder];
_totalSupply = _totalSupply.sub(extraTokensAmount);
balances[tokenHolder] = 0;
emit Burn(tokenHolder, extraTokensAmount);
}
using System;
using System.IO;
using System.Linq;
using Neo;
using Neo.VM;
using Neo.Cryptography;
namespace ConsoleApplication1
{
class program
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);
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;
}
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'))
public class NavigineReceiverExample extends BroadcastReceiver {
// here you need to receive some action from intent and depending on this action start service or set repeating alarm
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
try{
if (action.equals("START")) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context, 0,