Skip to content

Instantly share code, notes, and snippets.

const batch = window.web3.createBatch();
const tasks = transactions.map(tx => new Promise((resolve, reject) => {
const txData = tx.data.transaction;
// txData is a raw transaction that looks like:
// {
// nonce: nonce,
// gasPrice: web3.toHex(web3.toWei('20', 'gwei')),
// gasLimit: 100000,
// to: address,
// value: 0,
function buy(address _reserveToken, uint256 _depositAmount, uint256 _minimumValue) public returns (uint256 value) {
uint8 reserveRatio = reserveRatioOf[_reserveToken];
if (reserveRatio == 0 || _depositAmount == 0) // validate input
throw;
if (stage != Stage.Traded) // validate state
throw;
ReserveToken reserveToken = ReserveToken(_reserveToken);
uint256 reserveBalance = reserveToken.balanceOf(this);
import math
def isPalindrome(num):
# gets a number and checks if its Palindrome
x = num;
y = 0;
while (num > 0):
dig = num % 10;
y = y * 10 + dig;
num = num / 10;