GithubHelp home page GithubHelp logo

BEP-20 transaction about ethereum-tx HOT 5 CLOSED

array-drian avatar array-drian commented on May 24, 2024
BEP-20 transaction

from ethereum-tx.

Comments (5)

sc0Vu avatar sc0Vu commented on May 24, 2024 1

Hey @Razorholt, you have to fetch nonce from blockchain state with getTransactionCount(). In EVM based blockchain, it'll checkout the nonce in their state database.

from ethereum-tx.

sc0Vu avatar sc0Vu commented on May 24, 2024

Hi Did it work?

from ethereum-tx.

array-drian avatar array-drian commented on May 24, 2024

Hi Did it work?

No and I really dont know what I am doing wrong

from ethereum-tx.

Razorholt avatar Razorholt commented on May 24, 2024

still no luck?

from ethereum-tx.

tianheng2017 avatar tianheng2017 commented on May 24, 2024

Hello, so I am pretty new to this kind of coding and wanted to create a function to sent bnb transactions(0.1bnb gasprive 10gwei, gaslimit 21000). For now I am using the testnetwork and I just cant get it to work. Thanks in advance.

use Web3\Web3;
use Web3p\EthereumTx\Transaction;

$web3 = new Web3('https://data-seed-prebsc-1-s1.binance.org:8545');
$eth = $web3->eth;

$transaction = new Transaction([
    'nonce' => '0x' . bin2hex(makeRandomString()),
    'from' => "0x73AdF374419E4BAaDDC243e2250d6f6661D0Ff46",
    'to' => "0x367A32ba87E10e3AdAE8C60546B9383c78a3841A",
    'gas' => '0x' . dechex(21000),
    'gasPrice' => '0x' . dechex(10000000000),
    'value' => '0x' . dechex(100000000),
    'chainId' => 97
]);

$signedTransaction = $transaction->sign($privatekey);

$eth->sendRawTransaction('0x'. $signedTransaction, function ($err, $tx) {
    if ($err !== null) {
        $err->getMessage();
    }
    echo 'TX: '. $tx . PHP_EOL;
});

function makeRandomString($bits = 256) {
    $bytes = ceil($bits / 8);
    $return = '';
    for ($i = 0; $i < $bytes; $i++) {
        $return .= chr(mt_rand(0, 255));
    }
    return $return;
}`

傻屌,nonce不能用随机数,用getTransactionCount获取

from ethereum-tx.

Related Issues (20)

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.