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 {
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 {
@artiya4u
artiya4u / gen_binance_wallet.tcl
Last active May 14, 2019 08:03
Script to generate Binance chain wallet for testnet.
#!/usr/bin/expect
set timeout 20
for {set x 1} {$x<=20} {incr x} {
spawn tbnbcli keys add [format "wallet_%02d" $x]
expect "Enter a passphrase for your key:"
send "password\r";
expect "Repeat the passphrase:"
send "password\r";
interact
}