Giter VIP home page Giter VIP logo

tron-box's Introduction

tron-box's People

Contributors

dinhha avatar kookiekrak avatar sullof avatar tycm4109 avatar ujwalbattar avatar unforgivenzzz avatar zhaohong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tron-box's Issues

can't find my deployed contract address

tronbox migrate --reset
Using network 'development'.

Running migration: 1_initial_migration.js
Replacing Migrations...
Migrations:
(base58) TV7PkRBUPwzreB7cgX9rMe7mq3uVCUmjeg
(hex) 41d1f6b06f77eae2b20cbab9cbc3ac9e28726919f9
Saving successful migration to network...
Saving artifacts...

After this ,I still can't find my contract address on shasita testnet explorer,why?
https://explorer.shasta.trongrid.io/transaction/1a5cd7d115503e62c1e9715b69b4e9d8bb329d257cb78f8dcd601c7d3942efee

testnet address and pk:
TNx43yPrp5mitcnTwUmcVgpuRK7GniAhJT

ecf8b21fb49c20851f85d66e9f51ff2f56248a9af6bb9456cece36186782e473

CONTRACT_VALIDATE_ERROR

`pragma solidity ^0.4.25;

// * Uses hybrid commit-reveal + block hash random number generation that is immune
// to tampering by players, house and miners. Apart from being fully transparent,
// this also allows arbitrarily high bets.
//
// * Refer to https://dice2.win/whitepaper.pdf for detailed description and proofs.

contract Dice2Win {
/// *** Constants section

// Each bet is deducted 1% in favour of the house, but no less than some minimum.
// The lower bound is dictated by gas costs of the settleBet transaction, providing
// headroom for up to 10 Gsun prices.
uint constant HOUSE_EDGE_PERCENT = 1;
uint constant HOUSE_EDGE_MINIMUM_AMOUNT = 0.0003 trx;

// Bets lower than this amount do not participate in jackpot rolls (and are
// not deducted JACKPOT_FEE).
uint constant MIN_JACKPOT_BET = 0.1 trx;

// Chance to win jackpot (currently 0.1%) and fee deducted into jackpot fund.
uint constant JACKPOT_MODULO = 1000;
uint constant JACKPOT_FEE = 0.001 trx;

// There is minimum and maximum bets.
uint constant MIN_BET = 0.01 trx;
uint constant MAX_AMOUNT = 300000 trx;

// Modulo is a number of equiprobable outcomes in a game:
//  - 2 for coin flip
//  - 6 for dice
//  - 6*6 = 36 for double dice
//  - 100 for trxoll
//  - 37 for roulette
//  etc.
// It's called so because 256-bit entropy is treated like a huge integer and
// the remainder of its division by modulo is considered bet outcome.
uint constant MAX_MODULO = 100;

// For modulos below this threshold rolls are checked against a bit mask,
// thus allowing betting on any combination of outcomes. For example, given
// modulo 6 for dice, 101000 mask (base-2, big endian) means betting on
// 4 and 6; for games with modulos higher than threshold (Etheroll), a simple
// limit is used, allowing betting on any outcome in [0, N) range.
//
// The specific value is dictated by the fact that 256-bit intermediate
// multiplication result allows implementing population count efficiently
// for numbers that are up to 42 bits, and 40 is the highest multiple of
// eight below 42.
uint constant MAX_MASK_MODULO = 40;

// This is a check on bet mask overflow.
uint constant MAX_BET_MASK = 2 ** MAX_MASK_MODULO;

// EVM BLOCKHASH opcode can query no further than 256 blocks into the
// past. Given that settleBet uses block hash of placeBet as one of
// complementary entropy sources, we cannot process bets older than this
// threshold. On rare occasions dice2.win croupier may fail to invoke
// settleBet in this timespan due to technical issues or extreme Ethereum
// congestion; such bets can be refunded via invoking refundBet.
uint constant BET_EXPIRATION_BLOCKS = 250;

// Some deliberately invalid address to initialize the secret signer with.
// Forces maintainers to invoke setSecretSigner before processing any bets.
address constant DUMMY_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

// Standard contract ownership transfer.
address public owner;
address private nextOwner;

// Adjustable max bet profit. Used to cap bets against dynamic odds.
uint public maxProfit;

// The address corresponding to a private key used to sign placeBet commits.
address public secretSigner;

// Accumulated jackpot fund.
uint128 public jackpotSize;

// Funds that are locked in potentially winning bets. Prevents contract from
// committing to bets it cannot pay out.
uint128 public lockedInBets;

// A structure representing a single bet.
struct Bet {
    // Wager amount in sun.
    uint amount;
    // Modulo of a game.
    uint8 modulo;
    // Number of winning outcomes, used to compute winning payment (* modulo/rollUnder),
    // and used instead of mask for games with modulo > MAX_MASK_MODULO.
    uint8 rollUnder;
    // Block number of placeBet tx.
    uint40 placeBlockNumber;
    // Bit mask representing winning bet outcomes (see MAX_MASK_MODULO comment).
    uint40 mask;
    // Address of a gambler, used to pay out winning bets.
    address gambler;
}

// Mapping from commits to all currently active & processed bets.
mapping (uint => Bet) bets;

// Croupier account.
address public croupier;

// Events that are issued to make statistic recovery easier.
event FailedPayment(address indexed beneficiary, uint amount);
event Payment(address indexed beneficiary, uint amount);
event JackpotPayment(address indexed beneficiary, uint amount);

// This event is emitted in placeBet to record commit in the logs.
event Commit(uint commit);

// Constructor. Deliberately does not take any parameters.
constructor () public {
    owner = msg.sender;
    secretSigner = DUMMY_ADDRESS;
    croupier = DUMMY_ADDRESS;
}

// Standard modifier on methods invokable only by contract owner.
modifier onlyOwner {
    require (msg.sender == owner, "OnlyOwner methods called by non-owner.");
    _;
}

// Standard modifier on methods invokable only by contract owner.
modifier onlyCroupier {
    require (msg.sender == croupier, "OnlyCroupier methods called by non-croupier.");
    _;
}

// Standard contract ownership transfer implementation,
function approveNextOwner(address _nextOwner) external onlyOwner {
    require (_nextOwner != owner, "Cannot approve current owner.");
    nextOwner = _nextOwner;
}

function acceptNextOwner() external {
    require (msg.sender == nextOwner, "Can only accept preapproved new owner.");
    owner = nextOwner;
}

// Fallback function deliberately left empty. It's primary use case
// is to top up the bank roll.
function () public payable {
}

// See comment for "secretSigner" variable.
function setSecretSigner(address newSecretSigner) external onlyOwner {
    secretSigner = newSecretSigner;
}

// Change the croupier address.
function setCroupier(address newCroupier) external onlyOwner {
    croupier = newCroupier;
}

// Change max bet reward. Setting this to zero effectively disables betting.
function setMaxProfit(uint _maxProfit) public onlyOwner {
    require (_maxProfit < MAX_AMOUNT, "maxProfit should be a sane number.");
    maxProfit = _maxProfit;
}

// This function is used to bump up the jackpot fund. Cannot be used to lower it.
function increaseJackpot(uint increaseAmount) external onlyOwner {
    require (increaseAmount <= address(this).balance, "Increase amount larger than balance.");
    require (jackpotSize + lockedInBets + increaseAmount <= address(this).balance, "Not enough funds.");
    jackpotSize += uint128(increaseAmount);
}

// Funds withdrawal to cover costs of dice2.win operation.
function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner {
    require (withdrawAmount <= address(this).balance, "Increase amount larger than balance.");
    require (jackpotSize + lockedInBets + withdrawAmount <= address(this).balance, "Not enough funds.");
    sendFunds(beneficiary, withdrawAmount, withdrawAmount);
}

// Contract may be destroyed only when there are no ongoing bets,
// either settled or refunded. All funds are transferred to contract owner.
function kill() external onlyOwner {
    require (lockedInBets == 0, "All bets should be processed (settled or refunded) before self-destruct.");
    selfdestruct(owner);
}

/// *** Betting logic

// Bet states:
//  amount == 0 && gambler == 0 - 'clean' (can place a bet)
//  amount != 0 && gambler != 0 - 'active' (can be settled or refunded)
//  amount == 0 && gambler != 0 - 'processed' (can clean storage)
//
//  NOTE: Storage cleaning is not implemented in this contract version; it will be added
//        with the next upgrade to prevent polluting Ethereum state with expired bets.

// Bet placing transaction - issued by the player.
//  betMask         - bet outcomes bit mask for modulo <= MAX_MASK_MODULO,
//                    [0, betMask) for larger modulos.
//  modulo          - game modulo.
//  commitLastBlock - number of the maximum block where "commit" is still considered valid.
//  commit          - Keccak256 hash of some secret "reveal" random number, to be supplied
//                    by the dice2.win croupier bot in the settleBet transaction. Supplying
//                    "commit" ensures that "reveal" cannot be changed behind the scenes
//                    after placeBet have been mined.
//  r, s            - components of ECDSA signature of (commitLastBlock, commit). v is
//                    guaranteed to always equal 27.
//
// Commit, being essentially random 256-bit number, is used as a unique bet identifier in
// the 'bets' mapping.
//
// Commits are signed with a block limit to ensure that they are used at most once - otherwise
// it would be possible for a miner to place a bet with a known commit/reveal pair and tamper
// with the blockhash. Croupier guarantees that commitLastBlock will always be not greater than
// placeBet block number plus BET_EXPIRATION_BLOCKS. See whitepaper for details.
function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, bytes32 r, bytes32 s) external payable {
    // Check that the bet is in 'clean' state.
    Bet storage bet = bets[commit];
    require (bet.gambler == address(0), "Bet should be in a 'clean' state.");

    // Validate input data ranges.
    uint amount = msg.value;
    require (modulo > 1 && modulo <= MAX_MODULO, "Modulo should be within range.");
    require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be within range.");
    require (betMask > 0 && betMask < MAX_BET_MASK, "Mask should be within range.");

    // Check that commit is valid - it has not expired and its signature is valid.
    require (block.number <= commitLastBlock, "Commit has expired.");
    bytes32 signatureHash = keccak256(abi.encodePacked(uint40(commitLastBlock), commit));
    require (secretSigner == ecrecover(signatureHash, 27, r, s), "ECDSA signature is not valid.");

    uint rollUnder;
    uint mask;

    if (modulo <= MAX_MASK_MODULO) {
        // Small modulo games specify bet outcomes via bit mask.
        // rollUnder is a number of 1 bits in this mask (population count).
        // This magic looking formula is an efficient way to compute population
        // count on EVM for numbers below 2**40. For detailed proof consult
        // the dice2.win whitepaper.
        rollUnder = ((betMask * POPCNT_MULT) & POPCNT_MASK) % POPCNT_MODULO;
        mask = betMask;
    } else {
        // Larger modulos specify the right edge of half-open interval of
        // winning bet outcomes.
        require (betMask > 0 && betMask <= modulo, "High modulo range, betMask larger than modulo.");
        rollUnder = betMask;
    }

    // Winning amount and jackpot increase.
    uint possibleWinAmount;
    uint jackpotFee;

    (possibleWinAmount, jackpotFee) = getDiceWinAmount(amount, modulo, rollUnder);

    // Enforce max profit limit.
    require (possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");

    // Lock funds.
    lockedInBets += uint128(possibleWinAmount);
    jackpotSize += uint128(jackpotFee);

    // Check whether contract has enough funds to process this bet.
    require (jackpotSize + lockedInBets <= address(this).balance, "Cannot afford to lose this bet.");

    // Record commit in logs.
    emit Commit(commit);

    // Store bet parameters on blockchain.
    bet.amount = amount;
    bet.modulo = uint8(modulo);
    bet.rollUnder = uint8(rollUnder);
    bet.placeBlockNumber = uint40(block.number);
    bet.mask = uint40(mask);
    bet.gambler = msg.sender;
}

// This is the method used to settle 99% of bets. To process a bet with a specific
// "commit", settleBet should supply a "reveal" number that would Keccak256-hash to
// "commit". "blockHash" is the block hash of placeBet block as seen by croupier; it
// is additionally asserted to prevent changing the bet outcomes on Ethereum reorgs.
function settleBet(uint reveal, bytes32 blockHash) external onlyCroupier {
    uint commit = uint(keccak256(abi.encodePacked(reveal)));

    Bet storage bet = bets[commit];
    uint placeBlockNumber = bet.placeBlockNumber;

    // Check that bet has not expired yet (see comment to BET_EXPIRATION_BLOCKS).
    require (block.number > placeBlockNumber, "settleBet in the same block as placeBet, or before.");
    require (block.number <= placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");
    require (blockhash(placeBlockNumber) == blockHash);

    // Settle bet using reveal and blockHash as entropy sources.
    settleBetCommon(bet, reveal, blockHash);
}

// This method is used to settle a bet that was mined into an uncle block. At this
// point the player was shown some bet outcome, but the blockhash at placeBet height
// is different because of Ethereum chain reorg. We supply a full merkle proof of the
// placeBet transaction receipt to provide untamperable evidence that uncle block hash
// indeed was present on-chain at some point.
function settleBetUncleMerkleProof(uint reveal, uint40 canonicalBlockNumber) external onlyCroupier {
    // "commit" for bet settlement can only be obtained by hashing a "reveal".
    uint commit = uint(keccak256(abi.encodePacked(reveal)));

    Bet storage bet = bets[commit];

    // Check that canonical block hash can still be verified.
    require (block.number <= canonicalBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");

    // Verify placeBet receipt.
    requireCorrectReceipt(4 + 32 + 32 + 4);

    // Reconstruct canonical & uncle block hashes from a receipt merkle proof, verify them.
    bytes32 canonicalHash;
    bytes32 uncleHash;
    (canonicalHash, uncleHash) = verifyMerkleProof(commit, 4 + 32 + 32);
    require (blockhash(canonicalBlockNumber) == canonicalHash);

    // Settle bet using reveal and uncleHash as entropy sources.
    settleBetCommon(bet, reveal, uncleHash);
}

// Common settlement code for settleBet & settleBetUncleMerkleProof.
function settleBetCommon(Bet storage bet, uint reveal, bytes32 entropyBlockHash) private {
    // Fetch bet parameters into local variables (to save gas).
    uint amount = bet.amount;
    uint modulo = bet.modulo;
    uint rollUnder = bet.rollUnder;
    address gambler = bet.gambler;

    // Check that bet is in 'active' state.
    require (amount != 0, "Bet should be in an 'active' state");

    // Move bet into 'processed' state already.
    bet.amount = 0;

    // The RNG - combine "reveal" and blockhash of placeBet using Keccak256. Miners
    // are not aware of "reveal" and cannot deduce it from "commit" (as Keccak256
    // preimage is intractable), and house is unable to alter the "reveal" after
    // placeBet have been mined (as Keccak256 collision finding is also intractable).
    bytes32 entropy = keccak256(abi.encodePacked(reveal, entropyBlockHash));

    // Do a roll by taking a modulo of entropy. Compute winning amount.
    uint dice = uint(entropy) % modulo;

    uint diceWinAmount;
    uint _jackpotFee;
    (diceWinAmount, _jackpotFee) = getDiceWinAmount(amount, modulo, rollUnder);

    uint diceWin = 0;
    uint jackpotWin = 0;

    // Determine dice outcome.
    if (modulo <= MAX_MASK_MODULO) {
        // For small modulo games, check the outcome against a bit mask.
        if ((2 ** dice) & bet.mask != 0) {
            diceWin = diceWinAmount;
        }

    } else {
        // For larger modulos, check inclusion into half-open interval.
        if (dice < rollUnder) {
            diceWin = diceWinAmount;
        }

    }

    // Unlock the bet amount, regardless of the outcome.
    lockedInBets -= uint128(diceWinAmount);

    // Roll for a jackpot (if eligible).
    if (amount >= MIN_JACKPOT_BET) {
        // The second modulo, statistically independent from the "main" dice roll.
        // Effectively you are playing two games at once!
        uint jackpotRng = (uint(entropy) / modulo) % JACKPOT_MODULO;

        // Bingo!
        if (jackpotRng == 0) {
            jackpotWin = jackpotSize;
            jackpotSize = 0;
        }
    }

    // Log jackpot win.
    if (jackpotWin > 0) {
        emit JackpotPayment(gambler, jackpotWin);
    }

    // Send the funds to gambler.
    sendFunds(gambler, diceWin + jackpotWin == 0 ? 1 sun : diceWin + jackpotWin, diceWin);
}

// Refund transaction - return the bet amount of a roll that was not processed in a
// due timeframe. Processing such blocks is not possible due to EVM limitations (see
// BET_EXPIRATION_BLOCKS comment above for details). In case you ever find yourself
// in a situation like this, just contact the dice2.win support, however nothing
// precludes you from invoking this method yourself.
function refundBet(uint commit) external {
    // Check that bet is in 'active' state.
    Bet storage bet = bets[commit];
    uint amount = bet.amount;

    require (amount != 0, "Bet should be in an 'active' state");

    // Check that bet has already expired.
    require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");

    // Move bet into 'processed' state, release funds.
    bet.amount = 0;

    uint diceWinAmount;
    uint jackpotFee;
    (diceWinAmount, jackpotFee) = getDiceWinAmount(amount, bet.modulo, bet.rollUnder);

    lockedInBets -= uint128(diceWinAmount);
    jackpotSize -= uint128(jackpotFee);

    // Send the refund.
    sendFunds(bet.gambler, amount, amount);
}

// Get the expected win amount after house edge is subtracted.
function getDiceWinAmount(uint amount, uint modulo, uint rollUnder) private pure returns (uint winAmount, uint jackpotFee) {
    require (0 < rollUnder && rollUnder <= modulo, "Win probability out of range.");

    jackpotFee = amount >= MIN_JACKPOT_BET ? JACKPOT_FEE : 0;

    uint houseEdge = amount * HOUSE_EDGE_PERCENT / 100;

    if (houseEdge < HOUSE_EDGE_MINIMUM_AMOUNT) {
        houseEdge = HOUSE_EDGE_MINIMUM_AMOUNT;
    }

    require (houseEdge + jackpotFee <= amount, "Bet doesn't even cover house edge.");
    winAmount = (amount - houseEdge - jackpotFee) * modulo / rollUnder;
}

// Helper routine to process the payment.
function sendFunds(address beneficiary, uint amount, uint successLogAmount) private {
    if (beneficiary.send(amount)) {
        emit Payment(beneficiary, successLogAmount);
    } else {
        emit FailedPayment(beneficiary, amount);
    }
}

// This are some constants making O(1) population count in placeBet possible.
// See whitepaper for intuition and proofs behind it.
uint constant POPCNT_MULT = 0x0000000000002000000000100000000008000000000400000000020000000001;
uint constant POPCNT_MASK = 0x0001041041041041041041041041041041041041041041041041041041041041;
uint constant POPCNT_MODULO = 0x3F;

// *** Merkle proofs.

// This helpers are used to verify cryptographic proofs of placeBet inclusion into
// uncle blocks. They are used to prevent bet outcome changing on Ethereum reorgs without
// compromising the security of the smart contract. Proof data is appended to the input data
// in a simple prefix length format and does not adhere to the ABI.
// Invariants checked:
//  - receipt trie entry contains a (1) successful transaction (2) directed at this smart
//    contract (3) containing commit as a payload.
//  - receipt trie entry is a part of a valid merkle proof of a block header
//  - the block header is a part of uncle list of some block on canonical chain
// The implementation is optimized for gas cost and relies on the specifics of Ethereum internal data structures.
// Read the whitepaper for details.

// Helper to verify a full merkle proof starting from some seedHash (usually commit). "offset" is the location of the proof
// beginning in the calldata.
function verifyMerkleProof(uint seedHash, uint offset) pure private returns (bytes32 blockHash, bytes32 uncleHash) {
    // (Safe) assumption - nobody will write into RAM during this method invocation.
    uint scratchBuf1;  assembly { scratchBuf1 := mload(0x40) }

    uint uncleHeaderLength; uint blobLength; uint shift; uint hashSlot;

    // Verify merkle proofs up to uncle block header. Calldata layout is:
    //  - 2 byte big-endian slice length
    //  - 2 byte big-endian offset to the beginning of previous slice hash within the current slice (should be zeroed)
    //  - followed by the current slice verbatim
    for (;; offset += blobLength) {
        assembly { blobLength := and(calldataload(sub(offset, 30)), 0xffff) }
        if (blobLength == 0) {
            // Zero slice length marks the end of uncle proof.
            break;
        }

        assembly { shift := and(calldataload(sub(offset, 28)), 0xffff) }
        require (shift + 32 <= blobLength, "Shift bounds check.");

        offset += 4;
        assembly { hashSlot := calldataload(add(offset, shift)) }
        require (hashSlot == 0, "Non-empty hash slot.");

        assembly {
            calldatacopy(scratchBuf1, offset, blobLength)
            mstore(add(scratchBuf1, shift), seedHash)
            seedHash := keccak256(scratchBuf1, blobLength)
            uncleHeaderLength := blobLength
        }
    }

    // At this moment the uncle hash is known.
    uncleHash = bytes32(seedHash);

    // Construct the uncle list of a canonical block.
    uint scratchBuf2 = scratchBuf1 + uncleHeaderLength;
    uint unclesLength; assembly { unclesLength := and(calldataload(sub(offset, 28)), 0xffff) }
    uint unclesShift;  assembly { unclesShift := and(calldataload(sub(offset, 26)), 0xffff) }
    require (unclesShift + uncleHeaderLength <= unclesLength, "Shift bounds check.");

    offset += 6;
    assembly { calldatacopy(scratchBuf2, offset, unclesLength) }
    memcpy(scratchBuf2 + unclesShift, scratchBuf1, uncleHeaderLength);

    assembly { seedHash := keccak256(scratchBuf2, unclesLength) }

    offset += unclesLength;

    // Verify the canonical block header using the computed keccak256Uncles.
    assembly {
        blobLength := and(calldataload(sub(offset, 30)), 0xffff)
        shift := and(calldataload(sub(offset, 28)), 0xffff)
    }
    require (shift + 32 <= blobLength, "Shift bounds check.");

    offset += 4;
    assembly { hashSlot := calldataload(add(offset, shift)) }
    require (hashSlot == 0, "Non-empty hash slot.");

    assembly {
        calldatacopy(scratchBuf1, offset, blobLength)
        mstore(add(scratchBuf1, shift), seedHash)

        // At this moment the canonical block hash is known.
        blockHash := keccak256(scratchBuf1, blobLength)
    }
}

// Helper to check the placeBet receipt. "offset" is the location of the proof beginning in the calldata.
// RLP layout: [triePath, str([status, cumGasUsed, bloomFilter, [[address, [topics], data]])]
function requireCorrectReceipt(uint offset) view private {
    uint leafHeaderByte; assembly { leafHeaderByte := byte(0, calldataload(offset)) }

    require (leafHeaderByte >= 0xf7, "Receipt leaf longer than 55 bytes.");
    offset += leafHeaderByte - 0xf6;

    uint pathHeaderByte; assembly { pathHeaderByte := byte(0, calldataload(offset)) }

    if (pathHeaderByte <= 0x7f) {
        offset += 1;

    } else {
        require (pathHeaderByte >= 0x80 && pathHeaderByte <= 0xb7, "Path is an RLP string.");
        offset += pathHeaderByte - 0x7f;
    }

    uint receiptStringHeaderByte; assembly { receiptStringHeaderByte := byte(0, calldataload(offset)) }
    require (receiptStringHeaderByte == 0xb9, "Receipt string is always at least 256 bytes long, but less than 64k.");
    offset += 3;

    uint receiptHeaderByte; assembly { receiptHeaderByte := byte(0, calldataload(offset)) }
    require (receiptHeaderByte == 0xf9, "Receipt is always at least 256 bytes long, but less than 64k.");
    offset += 3;

    uint statusByte; assembly { statusByte := byte(0, calldataload(offset)) }
    require (statusByte == 0x1, "Status should be success.");
    offset += 1;

    uint cumGasHeaderByte; assembly { cumGasHeaderByte := byte(0, calldataload(offset)) }
    if (cumGasHeaderByte <= 0x7f) {
        offset += 1;

    } else {
        require (cumGasHeaderByte >= 0x80 && cumGasHeaderByte <= 0xb7, "Cumulative gas is an RLP string.");
        offset += cumGasHeaderByte - 0x7f;
    }

    uint bloomHeaderByte; assembly { bloomHeaderByte := byte(0, calldataload(offset)) }
    require (bloomHeaderByte == 0xb9, "Bloom filter is always 256 bytes long.");
    offset += 256 + 3;

    uint logsListHeaderByte; assembly { logsListHeaderByte := byte(0, calldataload(offset)) }
    require (logsListHeaderByte == 0xf8, "Logs list is less than 256 bytes long.");
    offset += 2;

    uint logEntryHeaderByte; assembly { logEntryHeaderByte := byte(0, calldataload(offset)) }
    require (logEntryHeaderByte == 0xf8, "Log entry is less than 256 bytes long.");
    offset += 2;

    uint addressHeaderByte; assembly { addressHeaderByte := byte(0, calldataload(offset)) }
    require (addressHeaderByte == 0x94, "Address is 20 bytes long.");

    uint logAddress; assembly { logAddress := and(calldataload(sub(offset, 11)), 0xffffffffffffffffffffffffffffffffffffffff) }
    require (logAddress == uint(address(this)));
}

// Memory copy.
function memcpy(uint dest, uint src, uint len) pure private {
    // Full 32 byte words
    for(; len >= 32; len -= 32) {
        assembly { mstore(dest, mload(src)) }
        dest += 32; src += 32;
    }

    // Remaining bytes
    uint mask = 256 ** (32 - len) - 1;
    assembly {
        let srcpart := and(mload(src), not(mask))
        let destpart := and(mload(dest), mask)
        mstore(dest, or(destpart, srcpart))
    }
}

}`

This is my tron contract contact.Tron studio compiles it successfully.
tronbox compile --all alos compiles successfully without a warning.

tronbox migrate --network development --reset
Using network 'development'.

Running migration: 1_initial_migration.js
Deploying Dice2Win...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Unknown error: {
"code": "CONTRACT_VALIDATE_ERROR",
"message": "636f6e74726163742076616c6964617465206572726f72203a20546865206f726967696e456e657267794c696d6974206d757374206265203e2030"
}
at /Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:135:1
at
at process._tickCallback (internal/process/next_tick.js:188:7)

Any suggestions?

tronbox migrate error

console
tronbox migrate --reset --network shasta
tronbox migrate --reset

node version v8.11.3

my tronbox.js config

module.exports = {
  networks: {
    development: {
// For trontools/quickstart docker image
      privateKey: '187a63bbada9ce4c9518903f88f3e4f7d1a2bd45c5a4159aec56a99733f28b39',
      consume_user_resource_percent: 30,
      fee_limit: 100000000,
      fullNode: "https://api.shasta.trongrid.io",
      solidityNode: "https://api.shasta.trongrid.io",
      eventServer: "https://api.shasta.trongrid.io",
      network_id: "*"
    },
    shasta: {
      privateKey: '187a63bbada9ce4c9518903f88f3e4f7d1a2bd45c5a4159aec56a99733f28b39',
      consume_user_resource_percent: 30,
      fee_limit: 100000000,
      fullNode: "https://api.shasta.trongrid.io",
      solidityNode: "https://api.shasta.trongrid.io",
      eventServer: "https://api.shasta.trongrid.io",
      network_id: "*"
    },
    mainnet: {
// Don't put your private key here, pass it using an env variable, like:
// PK=da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0 tronbox migrate --network mainnet
      privateKey: process.env.PK,
      consume_user_resource_percent: 30,
      fee_limit: 100000000,
      fullNode: "https://api.trongrid.io",
      solidityNode: "https://api.trongrid.io",
      eventServer: "https://api.trongrid.io",
      network_id: "*"
    }
  }
};

Using network 'shasta'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract has not been deployed on the network
    at /Users/jacob/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:135:1
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

can not catch revert error in uint test

tronbox : 2.3.1

in test_play.js

`
try{

        await instance.play(tronweb.sha3(uuid.v4()), payee,{
            shouldPollResponse:true
        })
        assert.fail()
    }catch(e){
        console.log(e)
    }`

tronbox test test_play.js output:
Contract: test play.sol
✓ call placeDice with valid parameters (13219ms)
ERROR: REVERT opcode executed

expect :
test pass

tronbox 2.1.9 works

How to enable optimizer

After upgrade to 2.2.1, contract deployment costs large fee from 8958000 to 569152600.
I think it's related to optimization of compiler. I tried add config like following, but it doesn't work

{
  solc: {
    optimizer: {
      enabled: true,
      runs: 200
    }
  },
  networks: {
    //...
  }
}

Will someone please explain this to me?

Tron-box is not using the version of solidity compiler I have installed. Why?
Screenshot_2019-05-07_08-04-24
Screenshot_2019-05-07_08-25-33

UPDATE: I see that the Solidity version is explicitly set in /packages/tron-solc/package.json.
Will changing this to 0.5.8 actually change the compiler version, or no?

I have tried RTFM, to no avail...
Screenshot_2019-05-07_10-28-58

UPDATE: Pull request submitted.
If I have made an error in my thinking please tell me. I want to help. Can we add a command that will use the specified version like: tronbox compile --version 0.5.8?

Tronbox migrate error - cannot connect to TronWeb

When I try to migrate contracts using:
tronbox migrate --reset --network shasta

I receive the following error:

ERROR: It was not possible to instantiate TronWeb. Some required parameters are missing in your "tronbox.js".

I used the default tronbox.js file, added my private key for the shasta wallet, which has shasta tron but still receive the error. What am I missing?

npm WARN tarball tarball data for tronbox@latest (sha512-hv4iQVmxUvhVkzfJc5YOew7aV0dJ+oE531hf+FLnvDs7CliP2T9gSoaM2xuKvbT7tVUJu0oGuQya/+gKaAnXCQ==) seems to be corrupted. Trying one more time.

Error:

npm install -g tronbox
npm WARN tarball tarball data for tronbox@latest (sha512-hv4iQVmxUvhVkzfJc5YOew7aV0dJ+oE531hf+FLnvDs7CliP2T9gSoaM2xuKvbT7tVUJu0oGuQya/+gKaAnXCQ==) seems to be corrupted. Trying one more time.
npm ERR! path C:\Users\Administrator\AppData\Roaming\npm\node_modules\.staging\tronbox-05a8d6ae\build\cli.bundled.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\.staging\tronbox-05a8d6ae\build\cli.bundled.js'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\.staging\tronbox-05a8d6ae\build\cli.bundled.js']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\.staging\tronbox-05a8d6ae\build\cli.bundled.js'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\.staging\\tronbox-05a8d6ae\\build\\cli.bundled.js' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\.staging\\tronbox-05a8d6ae\\build\\cli.bundled.js\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\.staging\\tronbox-05a8d6ae\\build\\cli.bundled.js' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-04-29T10_07_52_636Z-debug.log

tronbox migrate error

tronbox version
Tronbox v2.1.9 (core: 4.1.13)
Solidity v0.4.24 (tron-solc)

node -v
v8.11.3

tronbox.js
module.exports = {
networks: {
development: {
from: 'TNx43yPrp5mitcnTwUmcVgpuRK7GniAhJT',
privateKey: '',
consume_user_resource_percent: 30,
fee_limit: 100000000,
host: "https://api.trongrid.io",
port: 8090,
fullNode: "https://api.shasta.trongrid.io",
solidityNode: "https://api.shasta.trongrid.io",
eventServer: "https://api.shasta.trongrid.io",
fullHost: "https://api.shasta.trongrid.io",
network_id: "*" // Match any network id
},
production: {}
}
};

tronbox migrate --reset --network shasta
TypeError: Cannot read property 'fullHost' of undefined
at init (/Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:48:1)
at Object.run (/Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/commands/migrate.js:43:1)
at Command.run (/Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/command.js:101:1)
at Object. (/Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/cli.js:16:1)
at webpack_require (/Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/webpack/bootstrap 8568e5ef8404e4e319d2:19:1)
at /Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/webpack/bootstrap 8568e5ef8404e4e319d2:65:1
at Object. (/Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/cli.bundled.js:71:10)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3

Cannot test sending TRX to contract method

There is no equivalent of tronWeb contract.method().send({....}) in tronmox testing suit.
So there is no way of testing payable methods.
The simplest method in solidity looks like this:

    function appendDividends() payable external returns (bool){
        _totalDividends = _totalDividends.add(msg.value);
    }

According to details that were discussed here: https://discordapp.com/channels/491685925227724801/496925563387248652/547411545785630720
there are no methods that could send TRX to a contract method. I've tried this code:

const contract = await tronWeb.contract().at(instance.address);
const result = await contract.appendDividends().send({
        callValue: dividendAmount,
         shouldPollResponse: false
 });
const result = await instance.appendDividends({
        callValue: dividendAmount,
        from: ownerAccount
 });

etc did not work. The contract balance was 0 after transfer in both cases. I've even tried to wait for at least 5secs before checking balance. But no luck

P.S. Using tron-quickstart docker image v1.2.6 + latest tronbox

P.P.S.

tried using shouldPullResponse:true
the result is:


  Error: the object {
  "error": "Cannot find result in solidity node"
  "transaction": {
    "raw_data": {
      "contract": [
        {
          "parameter": {
            "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
            "value": {
              "call_value": 5000000
              "contract_address": "41faf79f8767af46e3f3e63ffb39f9aa3ae544f634"
              "data": "ed55aab8"
              "owner_address": "41928c9af0651632157ef27a2cf17ca72c575a4d21"
            }
          }
          "type": "TriggerSmartContract"
        }
      ]
      "expiration": 1550588274000
      "fee_limit": 1000000000
      "ref_block_bytes": "0190"
      "ref_block_hash": "b32bd9083c623d55"
      "timestamp": 1550588215724
    }
    "signature": [
      "bf9e2826e3fff1e664e8ac7284556b98fd5e91799f2bec8b73dae19dd34f07f918bf4bf4f5c488eb9c3777bdd4d7ca421a2c8df6cadebf2e45276d719ac6717800"
    ]
    "txID": "b173b309524dc152f24361cf5fd198dd92fa9a673ac5e50144a392a84d32d60e"
  }
} was thrown, throw an Error :)

Smart Contract deployed on testnet shasta not getting searched.

using command tronbox migrate --reset --network shasta, I deployed smart contract on shasta testnetwork. Now, I am searching contract address on shasta explorer it is not there. why?

In tronbox.js I have defined shasta network as follows:

shasta: {
     privateKey: 'my PK',
     consume_user_resource_percent: 30,
     fee_limit: 100000000,
     fullNode: "https://api.shasta.trongrid.io",
     solidityNode: "https://api.shasta.trongrid.io",
     eventServer: "https://api.shasta.trongrid.io",
     network_id: "*"
   }

And I am searching on https://shasta.tronscan.org/#/

tronbox version; tronbox compile Invalid member of stdlib error

So I get an error when attempting to use tronbox commands: version, compile

tronbox version
Tronbox v2.3.9 (core: 4.1.13)
Solidity v0.4.24 (tron-solc)
(node:9960) V8: "MYPATH" npm\node_modules\tronbox\build\cli.bundled.js:171784 Invalid asm.js: Invalid member of stdlib
(node:9960) V8: "MYPATH" npm\node_modules\tronbox\build\cli.bundled.js:84002 Invalid asm.js: Invalid member of stdlib

Can not deploy after upgrade to 2.2.0

2.1.10 has problem "CONTRACT_VALIDATE_ERROR" #32
try to upgrade to 2.2.0, but it still doesn't work.

Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract has not been deployed on the network
    at /Users/emn178/inno/tron-joyso-contracts/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:136:1
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

tronbox migrate error

HI, I am getting below error while migrating...
Satyakams-MacBook-Pro:CodeXpert-Tron-DApp-Template satyakamchakravarty$ tronbox migrate --reset --network shasta
(node:19151) V8: /usr/local/lib/node_modules/tronbox/build/cli.bundled.js:171304 Invalid asm.js: Invalid member of stdlib
Using network 'shasta'.

Running migration: 1_initial_migration.js
Deploying Migrations...
ERROR: TypeError: Cannot read property 'code' of undefined
Satyakams-MacBook-Pro:CodeXpert-Tron-DApp-Template satyakamchakravarty$

Can't deploy a contract to development network

This is the output:

ERROR: Contract Main has not been deployed on the network. For more details, check the transaction at: http://127.0.0.1:9090/wallet/gettransactionbyid?value=11b8b39a2ef402e64b85b52460f257499ff57b2c9c3584e497fe515486d7e3fa If the transaction above is empty, most likely, your address had no bandwidth/energy to deploy the contract.

When I visit the link I get that values of:

"owner_address": "4182a280c3b0eed55e34067db5097e1f3c534094c2" "origin_address": "4182a280c3b0eed55e34067db5097e1f3c534094c2"

I run:

sudo curl http://127.0.0.1:9090/admin/accounts?format=all

Output is:

`
(0) TMswWuHormhNc2BUcq84AaGotpEpDGi6Z4 (8805.74373 TRX)
4182a280c3b0eed55e34067db5097e1f3c534094c2
(1) TM8QZcxwL9zmoaC8yf1tgL5Vei5SQYu9ZT (10000 TRX)
417a66c73bf0461ed17721f240e1d5b2187c59f42d
(2) TXseM9Gun2sZusWKWBX7Tu26E4aizy75ua (10000 TRX)
41f0456df2b7bb197739f063d09ffb57ea4feda5ea
(3) TQYn4d27hjuVNkfyqsMs6UgvBLkVEdRHnF (10000 TRX)
419feb160440c6197b4465795b077659f7010aed3d
(4) TF971r13J8oPcUPkGyrG5XkhFGsutou7SX (10000 TRX)
4138b7ca935960b35a633e084de888f3d146737210
(5) TEf9nmhSZ4a1b1YaDGRi98gsuGJ3fedAoh (10000 TRX)
41336e75e266be5e893cca973926d8235af2d8c19b
(6) TNd3nh6cpS93JK2638fvBTguC55gycF487 (10000 TRX)
418ac9a00961f7cccecccd11a689c931b6e0b90fb6
(7) TLayw8c1NVyMP2sbz8miucrTHhZwZyYSDD (10000 TRX)
41747552f777d607ea45abac0976844d554b60106a
(8) TTd1DbpNTw9sTyTz3HWHnvsNKjFdzqTGhS (10000 TRX)
41c1a01bb8b9244ee4f67788982ca3e32b7e921df9
(9) TYjd91VKXz2ebFZiTYPjt2uV8d9ZCa7Wjj (10000 TRX)
41f9b937da5d3ada1f2b3a3f022f52d1c556659fad

Private Keys

(0) b8dafcd5ed7e6b36a50efb40c4b811219ad10d88e2684976fc84931eb4d63652
(1) e41484bd5709396df86a91d5e84597aeb15675cbd3a24c6e981b0b606203f027
(2) 5910c8114dc73f4c14d85fe230918f1f14438e4c198dbe17652f90449c062f6a
(3) d61576100b877818166e4e0f2b75ed2bc6284c9d4711bcf32112f069a36dbabf
(4) 19b11b039e8207749de5d572a7c7fe3cd98b685d3c2a1f4c86013300800e3910
(5) 08c46cd3bfb5400427e1e37da8e695b2fe3fb86f125b4d02c3121120474b269b
(6) b101a1025ba78e6b6feb7df5d22bb7495d079c7152088b205ef0f97099c1977a
(7) 8545421796812cee565aee5ffa997bdf4af6c01439dbd8f8019825842e5ea3b9
(8) 70c3e8f083f58c18f05dc4dd6238f870845c48f183c54a238ddc5e06835c180a
(9) bd3a6302bf74cb8609e32b2dd5a29f31d938e28e4a6de80c26c30544fd9bb6bb

`

So it's the first address.

So the privateKey field in the developement object is set to it:

` development: {
// For trontools/quickstart docker image
privateKey: 'b8dafcd5ed7e6b36a50efb40c4b811219ad10d88e2684976fc84931eb4d63652',
userFeePercentage: 30, // or consume_user_resource_percent
feeLimit: 100000000, // or fee_limit
originEnergyLimit: 1e7, // or origin_energy_limit
callValue: 0, // or call_value
consume_user_resource_percent: 30,
fee_limit: 100000000,

  // Requires TronBox 2.1.9+ and Tron Quickstart 1.1.16+
  fullHost: "http://127.0.0.1:9090",

  // The three settings below for TronBox < 2.1.9
  //fullNode: "http://127.0.0.1:9090",
  //solidityNode: "http://127.0.0.1:9090",
  //eventServer: "http://127.0.0.1:9090",

  network_id: "*"
},`

Reading through these issues I read somewhere that privateKey should actually be: da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0.

I tried that as well, but I get the same error. But, the values of owner_address and origin_address are still the same hex for that first account.

TronBox version is 2.3.13

tronbox.js can't compile?

This is my tronbox.js :
module.exports = {
networks: {
shasta: {
privateKey: 'ac946f65e1337e85380d3649d4f6493ad719dbdee83f3aa0f882173603ae7f86',
consume_user_resource_percent: 30,
fee_limit: 100000000,

  // tronbox 2.1.9+
  // fullHost: "https://api.shasta.trongrid.io",

  // tronbox < 2.1.9
  fullNode: "https://api.shasta.trongrid.io",
  solidityNode: "https://api.shasta.trongrid.io",
  eventServer: "https://api.shasta.trongrid.io",

  network_id: "*"
}

}
}

I develop tron contract on Win7.When I compile contract , it's alter Microsoft jScript compile error .I don't know what's wrong with my deploy

pass array args in function would cause "Invalid argument count provided"

I try call the same contract in shasta by tronweb and tronbox with same args
but got error in tronbox

      "constant": false,
      "inputs": [
        {
          "name": "aa",
          "type": "uint256[]"


        }
      ],
      "name": "setValue",
      "outputs": [],
      "payable": false,
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ],

the above is the function's abi
2018-12-06 12 23 07
2018-12-06 12 25 01

tronbox migrate error: timeout of 30000ms exceeded

My log as below:
Using network 'shasta'.
Running migration: 1_initial_migration.js
Deploying Migrations...
ERROR: timeout of 30000ms exceeded

I use the latest tronbox
Tronbox v2.3.0 (core: 4.1.13)
Solidity v0.4.24 (tron-solc)
node version:
v8.11.3
In my test account,I have 29444 trx,and I've frozen 20000 trx.
console:
tronbox migrate --reset --network shasta
my config:
shasta: {
privateKey: 'cb0a71f555994dc693b69e935e4665962724ae63698b756f8053698ecc8368d8',
consume_user_resource_percent: 30,
fee_limit: 100000000,
fullNode: "https://api.shasta.trongrid.io",
solidityNode: "https://api.shasta.trongrid.io",
eventServer: "https://api.shasta.trongrid.io",
network_id: "*"
},

Contract function call return txID instead of value

I have some code in tests:

let instance = await RandomNumberGenerator.deployed();
let N = await instance.RNG(51);

After executing this code, I expect a random number in the N. But I get the transaction ID as a string.

How could I get what the contract function returns?

RandomNumberGenerator code:

contract RandomNumberGenerator {
  uint private rngCounter;

  constructor() public {
    rngCounter = 1;
  }
  //Generates a random number from 0 to X based on the last block hash
  //counter is added to "now" so that RNG doesnt produce same number if called twice in the same second
  function RNG(uint X) public returns (uint _randNum) {
    rngCounter *= 2;
    uint seed = now - rngCounter;
    _randNum = (uint(keccak256(abi.encodePacked(blockhash(block.number - 1), seed)))%X + 1);

    //reset RNG counter to prevent unecessary large number and overflow
    if(rngCounter > 420000000)
      rngCounter = _randNum;

    return _randNum;
  }
}

tronbox migrate error

yhws-MacBook-Pro:tronCraft yhw$ node -v
v11.4.0
yhws-MacBook-Pro:tronCraft yhw$ npm -v
6.4.1
yhws-MacBook-Pro:tronCraft yhw$ tronbox version
Tronbox v2.2.3-prev.0 (core: 4.1.13)
Solidity v0.4.24 (tron-solc)
(node:92317) V8: /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/cli.bundled.js:171268 Invalid asm.js: Invalid member of stdlib

yhws-MacBook-Pro:tronCraft yhw$ tronbox migrate --network shasta --reset
(node:92325) V8: /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/cli.bundled.js:171268 Invalid asm.js: Invalid member of stdlib
Using network 'shasta'.

Running migration: 1_initial_migration.js
Replacing Migrations...
Migrations:
(base58) TPGCQRvA1jGDCR81YekTJeDHcBbVrgoXCF
(hex) 4191d035496f360576c542835052ee03e1853ced83
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
Replacing CraftToken...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract has not been deployed on the network
at /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:158:1
at process.internalTickCallback (internal/process/next_tick.js:77:7)
yhws-MacBook-Pro:tronCraft yhw$ tronbox migrate --network shasta --reset
(node:92327) V8: /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/cli.bundled.js:171268 Invalid asm.js: Invalid member of stdlib
Using network 'shasta'.

Running migration: 1_initial_migration.js
Replacing Migrations...
Migrations:
(base58) TNZfUi5T45S6Z3jsu9hAcSKnzkz1iPMoES
(hex) 418a25c0f69c25d99c486eadbfbdc73467e613438a
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
Replacing CraftToken...
CraftToken:
(base58) TEsoNg9QS644x7pxHJxY4zexr9J9GVq1N3
(hex) 4135d2d37707c718043a53a59777f19020caf1abf4
Deploying CraftDice...
Deploying CraftSlots...
Saving successful migration to network...
Error: TypeError: e.reduce is not a function
at /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:158:1
at process.internalTickCallback (internal/process/next_tick.js:77:7)
Error: TypeError: e.reduce is not a function
at /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:158:1
at process.internalTickCallback (internal/process/next_tick.js:77:7)
Saving artifacts...

just hang here,CraftDice and CraftSlots migrate failed,help me ,please

this is my migrate js file:
`var CraftToken = artifacts.require("./CraftToken.sol");
var CraftDice = artifacts.require("./CraftDice.sol");
var CraftSlots = artifacts.require("./CraftSlots.sol");

var cftMinerAddr = "";
var tokenAddr = "";

module.exports = function (deployer) {
deployer.deploy(CraftToken, "CraftToken", "CFT", 6, "10000000000000000").then(function () {
// console.dir(CraftToken);
deployer.deploy(CraftDice, CraftToken.address, cftMinerAddr, {
fee_limit: 1e9,
userFeePercentage: 1,
originEnergyLimit: 1e7
}).catch(function (e) {
console.log(e);
});

    deployer.deploy(CraftSlots, CraftToken.address, cftMinerAddr, {
        fee_limit: 1e9,
        userFeePercentage: 1,
        originEnergyLimit: 1e7
    }).catch(function (e) {
        console.log(e);
    });

});

};`

can't change the account to deploy from

hi,

I managed to deploy my contract to Shasta network, but Tronbox deployed it from unknown account. When I saw contract's creator address, it wasn't what I expected to see. I thought It was going to deploy from the account which private key I put in tronbox.js, but it wasn't. So, why does tronbox need a private key in its config file? How to change deployer's address? Tried to add a field "from" in the config. It didn't work

tronbox migrate --reset --network shasta msg killed

I tried to deploy a contract, but I am getting an error when I execute "tronbox migrate --reset --network shasta". The error message was killed.
git clone https://github.com/sullof/metacoin-box.git
cd metacoin-box/
cd migrations/
vim tronbox.js

module.exports = {
  networks: {
    shasta: {
      privateKey: '8c86e28648c71a0b42c255f941c14d35b2a10148a83ae8ae6ed8254a7a93c0f8',
      consume_user_resource_percent: 30,
      fee_limit: 100000000,
      fullNode: "https://api.shasta.trongrid.io",
      solidityNode: "https://api.shasta.trongrid.io",
      eventServer: "https://api.shasta.trongrid.io",
      network_id: "*"
    },
  }
};

tronbox compile --compile-all

[root@izj6c28ftc1v9t3nkz3cofz metacoin-box]# tronbox compile --compile-all
(node:3696) V8: /usr/local/lib/node_modules/tronbox/build/cli.bundled.js:171823 Invalid asm.js: Invalid member of stdlib
(node:3696) V8: /usr/local/lib/node_modules/tronbox/build/cli.bundled.js:171793 Invalid asm.js: Invalid member of stdlib
(node:3696) V8: /usr/local/lib/node_modules/tronbox/build/cli.bundled.js:84011 Invalid asm.js: Invalid member of stdlib
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Writing artifacts to ./build/contracts

tronbox migrate --reset --network shasta

[root@izj6c28ftc1v9t3nkz3cofz metacoin-box]# tronbox migrate --network shasta
Killed

My operating system is Alibaba Cloud centos 7, 2 core cpu
Can you give me some advice?

tronbox migrating can not use the .at(contract address)

when writing following migratation script in tronbox, there will happen to some error. but that can work well in truffle, please check it, thanks!
let a = await A.at('4174ca9d500f00601b8e1db69734c05e04b7b67be8');

the errors show that:
(node:3722) UnhandledPromiseRejectionWarning: TypeError: this.getContract is not a function
at TronWrap.tronWrap._getContract (/usr/local/Cellar/node/11.2.0/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:135:1)
at /usr/local/Cellar/node/11.2.0/lib/node_modules/tronbox/build/webpack:/packages/truffle-contract/contract.js:413:1
at new Promise ()
at /usr/local/Cellar/node/11.2.0/lib/node_modules/tronbox/build/webpack:/packages/truffle-contract/contract.js:412:1
at new Promise ()

Compile command error

I am trying to follow the tutorial to run a DApp on the TRON test network using https://medium.com/tron-foundation/how-to-build-a-tron-dapp-5d377cd12061

I followed the instruction of the tutorial installed the tronbox tool using npm and clone.
When I execute tronbox compile command I get the following error:

stephanef@STEPHANE-PC /c/code/TronLink-Demo-Messages (master)
λ tronbox compile
C:\Users\stephanef\AppData\Roaming\nvm\v6.14.4\node_modules\tronbox\build\cli.bundled.js:1903
tronWrap._getContract = async function (address, callback) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)

Any clue what it could be?

deploy error

PS C:\Users\xing9\Documents\GitHub\Tron_Idol> tronbox migrate --reset

Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying Migrations...
Migrations:
(base58) TWNArsTTDv9ffeG2rr8st9HLv27yHBMNyy
(hex) 41dfba4ba174dbeb69e1dff782bc0e9203d23e8f1a
Deploying GeneScience...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract has not been deployed on the network
at C:\Users\xing9\AppData\Roaming\npm\node_modules\tronbox\build\webpack:\packages\tronwrap\index.js:158:1
at process._tickCallback (internal/process/next_tick.js:68:7)

PS C:\Users\xing9\Documents\GitHub\Tron_Idol> tronbox migrate --reset

Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying Migrations...
Migrations:
(base58) TJPCDtMQCE6w1QE3rArkmEnAuXvPBc12wz
(hex) 415c4a56d666b534ba8b81873d41b5105babe44beb
Deploying GeneScience...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract has not been deployed on the network
at C:\Users\xing9\AppData\Roaming\npm\node_modules\tronbox\build\webpack:\packages\tronwrap\index.js:158:1
at process._tickCallback (internal/process/next_tick.js:68:7)

PS C:\Users\xing9\Documents\GitHub\Tron_Idol> tronbox migrate --reset

Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying Migrations...
Deploying GeneScience...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract has not been deployed on the network
at C:\Users\xing9\AppData\Roaming\npm\node_modules\tronbox\build\webpack:\packages\tronwrap\index.js:158:1
at process._tickCallback (internal/process/next_tick.js:68:7)

PS C:\Users\xing9\Documents\GitHub\Tron_Idol> tronbox migrate --reset

Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying Migrations...
Migrations:
(base58) TSk58Hd9RKVS9Uo8ST2yyvt48fdmGuwsxB
(hex) 41b7fe28237c85400106e4dbd1e4fd80a9036ec4a6
Deploying GeneScience...
GeneScience:
(base58) TDJWBp4H15zNAuLCfJjJx5NKdwhhMZABHh
(hex) 41248ea0537c3c66d9b565f299d96d2819977ee5f9
Saving successful migration to network...
Saving artifacts...

PS C:\Users\xing9\Documents\GitHub\Tron_Idol>

I don't do anything between these operation. It failed before and succeeded at last.

ERROR: NOT_ENOUGH_EFFECTIVE_CONNECTION (effective connection:0 lt minEffectiveConnection:1) while broadcasting the transaction to create the contract Migrations

I am trying to migrate smart contract on private node using command tronbox migrate --reset --network new_network it is giving error

ERROR: NOT_ENOUGH_EFFECTIVE_CONNECTION (effective connection:0 lt minEffectiveConnection:1) while broadcasting the transaction to create the contract Migrations

When I try to deploy smart contract on shasta network, it works!
I created new network in tronbox.js file with the private key and node details.
Not getting this error's solution.

can not transfer trx to contract in tronbox test environment

Contract code has a fallback function to receive trx
function() payable public {}

tronbox test js transfer trx to user address and contract address. user can receive trx,but contract can not receive

await tronWeb.trx.sendTransaction('contract base58 address', 20000000,{from: accounts[0]});

tronbox migrate error

tronbox version
Tronbox v2.3.0 (core: 4.1.13)
Solidity v0.4.24 (tron-solc)
(node:92394) V8: /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/cli.bundled.js:171571 Invalid asm.js: Invalid member of stdlib
yhws-MacBook-Pro:tronCraft yhw$ node -v
v11.4.0
yhws-MacBook-Pro:tronCraft yhw$ tronbox migrate --network shasta --reset
(node:92397) V8: /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/cli.bundled.js:171571 Invalid asm.js: Invalid member of stdlib
Using network 'shasta'.

Running migration: 1_initial_migration.js
Replacing Migrations...
Migrations:
(base58) TSPiEDX12XjGHXhEV8Zvr9MdE4fVJLsfaX
(hex) 41b4246499effeac87a0a917cb39aae676cd5c5a24
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
Replacing CraftToken...
CraftToken:
(base58) THb24ogMahB6YncXNDgHvBi8KnbVnqJd5E
(hex) 41538eba08c07c1d126bda6725919083f81aa23502
Deploying CraftDice...
Deploying CraftSlots...
Saving successful migration to network...
Error: Error: invalid address (arg="", coderType="address", value="", version=4.0.7)
at /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:166:1
at process.internalTickCallback (internal/process/next_tick.js:77:7)
Error: Error: invalid address (arg="", coderType="address", value="", version=4.0.7)
at /Users/yhw/.nvm/versions/node/v11.4.0/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:166:1
at process.internalTickCallback (internal/process/next_tick.js:77:7)
Saving artifacts...

here is my migrate js:
`var CraftToken = artifacts.require("./CraftToken.sol");
var CraftDice = artifacts.require("./CraftDice.sol");
var CraftSlots = artifacts.require("./CraftSlots.sol");

var cftMinerAddr = "";
var tokenAddr = "";

module.exports = function (deployer) {
deployer.deploy(CraftToken, "CraftToken", "CFT", 6, "10000000000000000").then(function () {
// console.dir(CraftToken);
deployer.deploy(CraftDice, CraftToken.address, cftMinerAddr, {
fee_limit: 1e9,
userFeePercentage: 1,
originEnergyLimit: 1e7
}).catch(function (e) {
console.log(e);
});

    deployer.deploy(CraftSlots, CraftToken.address, cftMinerAddr, {
        fee_limit: 1e9,
        userFeePercentage: 1,
        originEnergyLimit: 1e7
    }).catch(function (e) {
        console.log(e);
    });

});

};`

compile and migrate error

Can someone help me?
My tronbox is latest,
Tronbox v2.2.3-prev.0 (core: 4.1.13)
Solidity v0.4.24 (tron-solc)
(node:26413) V8: /usr/lib/node_modules/tronbox/build/cli.bundled.js:171268 Invalid asm.js: Invalid member of stdlib
my code is below:
https://github.com/whitespur/tron-dapp-demo/blob/master/contracts/Token.sol
the same as :https://github.com/maxisacoder/tron-dapp-demo/issues/1
when I

tronbox compile

error as below:
`Warning: This is a pre-release compiler version, please do not use it in production.
,/root/tron/test/contracts/Token.sol:19:5: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
function Token(
^ (Relevant source part starts here and spans across multiple lines).

Warning: This is a pre-release compiler version, please do not use it in production.
,/root/tron/test/contracts/Token.sol:19:5: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
function Token(
^ (Relevant source part starts here and spans across multiple lines).
,/root/tron/test/contracts/Token.sol:26:9: DeclarationError: Undeclared identifier.
totalSupply = _initialAmount; // Update total supply
^---------^
,/root/tron/test/contracts/Token.sol:36:14: DeclarationError: Undeclared identifier. Did you mean "transfer"?
emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
^------^
,/root/tron/test/contracts/Token.sol:48:14: DeclarationError: Undeclared identifier. Did you mean "transfer"?
emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
^------^
,/root/tron/test/contracts/Token.sol:58:14: DeclarationError: Undeclared identifier.
emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
^------^
Compilation failed. See above.`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.