using web3@1.0.0-beta.33 and react-native@0.59.10, because latest web3 have install issue on react-native, after deep research 1.0.0-beta.33 is suitable on react-native

const web3 = new Web3("https://mainnet.infura.io:443"); 
var count = await web3.eth.getTransactionCount(this.state.selectedWallet.publicaddress);
var contractdata = new web3.eth.Contract(abiArray, SensitiveInfo.tokencontract);
var rawTransaction = {
    "from": this.state.selectedWallet.publicaddress,
    "nonce": count,
    "gasPrice": 4500000000,
    "gas": web3.utils.toHex("519990"),
    "to": SensitiveInfo.tokencontract,
    "value": "0x0",
    "data": contractdata.methods.transfer(this.state.recipientaddress,web3.utils.toWei('1', 'ether')).encodeABI(),
    "chainId": 0x01
var privKey = new Buffer(this.state.selectedWallet.privatekey,'hex');
var tx = new Tx(rawTransaction);
var serializedTx = tx.serialize();
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), (err, hash) =>{
  if (!err) //SUCCESS



  1. the same code base use in web are work, but web3@1.2.1
  2. I can very confirmed the from address have enough token and gas
  3. have do research said change all hex to number, like gas , gasLimit, value and chainId
  • How much ether do you have in this.state.selectedWallet.publicaddress? – goodvibration Aug 24 '19 at 19:22
  • @goodvibration enough to do the transaction , because it work in web – FeelRightz Aug 25 '19 at 3:56
  • Well, maybe there isn't enough after you've executed it already. In any case, I recommend using beta-34, which I know to be stable. Beta-37 is also known to be stable (version 1.2.0 is based on it; not sure about version 1.2.1). Other beta versions are not stable AFAIK. – goodvibration Aug 25 '19 at 5:29
  • @goodvibration just tried what you suggest 34 and 37, 34 have exact same problem as question say, 37 have same problem when install 1.2.1 , as this link stackoverflow.com/questions/57613819/… – FeelRightz Aug 25 '19 at 6:00
  • 1
    BTW, gas and gasLimit are the same. – goodvibration Aug 25 '19 at 9:54

With web3 1.0.0-beta.34, you can try this:

async function send(transaction, privateKey) {
    const options = {
        to      : transaction._parent._address,
        data    : transaction.encodeABI(),
        gasPrice: "4500000000",
        gas     : "519990",
        value   : "0"
    const signed  = await web3.eth.accounts.signTransaction(options, privateKey);
    const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);
    return receipt;

Usage example:

const to      = this.state.recipientaddress;
const value   = web3.utils.toWei("1", "ether");
const key     = this.state.selectedWallet.privatekey;
const receipt = await send(contractdata.methods.transfer(to, value), key);
| improve this answer | |
  • after some try , i find out it was my private key issue, but web3 doesn't error me the correct way, thats why i keep stuck on gas and value, anyway thanks for inform me to use 34 for stable version. Although your answer i haven't try, but consider it might help others, so I will mark as correct ! Thanks a lot ! – FeelRightz Aug 26 '19 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.