Skip to content

Instantly share code, notes, and snippets.

module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*" // match any network
},
live: {
host: "88.88.88.88", // Random IP for example purposes (do not use)
port: 80,
@artiya4u
artiya4u / 2_deploy_contracts.js
Last active March 3, 2018 11:10
2_deploy_contracts.js
const BNK48CoinCrowdSale = artifacts.require("BNK48CoinCrowdSale");
const BNK48Coin = artifacts.require("BNK48Coin");
const RefundVault = artifacts.require("RefundVault");
function ether(n) {
return new web3.BigNumber(web3.toWei(n, 'ether'));
}
module.exports = function (deployer, network, accounts) {
const startTime = new web3.BigNumber(Math.floor(new Date().getTime() / 1000)); // Now
pragma solidity ^0.4.18;
// File: zeppelin-solidity/contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
pragma solidity ^0.4.18;
// File: zeppelin-solidity/contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
pragma solidity ^0.4.18;
// File: zeppelin-solidity/contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
pragma solidity ^0.4.18;
// File: zeppelin-solidity/contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
#!/usr/bin/env python
# This software is Copyright (c) 2017, Dhiru Kholia <dhiru.kholia at gmail.com>
# and it is hereby released to the general public under the following terms:
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
#
# Special thanks goes to @Chick3nman for coming up with the output hash format.
#
pragma solidity ^0.4.21;
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "zeppelin-solidity/contracts/math/SafeMath.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
contract Subscription is Ownable {
using SafeMath for uint256;
const Web3 = require('web3');
const abi = require('./abi.json'); // ABI of Subscription.sol in "build" directory on truffle project.
// noinspection JSUnresolvedVariable
const web3 = new Web3(
new Web3.providers.WebsocketProvider(config.contract.provider),
);
const subscriptionContract = new web3.eth.Contract(
abi,
@artiya4u
artiya4u / random_with_weight.go
Last active September 22, 2018 02:54
Demo algorithm to get the random choice with different weight.
package main
import (
"fmt"
"math/rand"
)
func randomWithWeight(weights []int) int {
var sum int
for _, v := range weights {