9

You can get both using the web3 instance of web3.js: const networkId = await web3.eth.net.getId(); const chainId = await web3.eth.getChainId();


5

This is happening because ethereumjs-tx library has changed its syntax. This is the working version of your code: const EthereumTx = require('ethereumjs-tx').Transaction var Web3 = require('web3') var web3 = new Web3('http://127.0.0.1:7545') //Setting Receiving and Sending Address var sendingAddress = 'ADD SENDING ADDRESS HERE' var receivingAddress = '...


4

I don't know if that's a proper way of sending a raw transaction, but it works. Just tested it. const Web3 = require('web3'); const Tx = require('ethereumjs-tx'); const config = require('./config'); const web3 = new Web3(new Web3.providers.HttpProvider(config.provider)); //link provided by Infura.io web3.eth.defaultAccount = "...


4

You're calling getBalance, which returns the amount of ether (in wei) that the account holds. You're then passing that amount in the value field of the transaction, so the transaction is going to attempt to send the entire balance of the account. This is why the amount goes up when you add more funds to the account. Such a transaction will never succeed, ...


4

Answer to my question //Admin's eth Address ------------ const account1 = process.env.ADMIN_ETH_ADDR; //Admin's eth private key ----------------- const ac1_pvtkey = Buffer.from(process.env.ADMIN_ETH_PVT_KEY, 'hex'); Actual Transaction creation -> signing tx -> serializing tx -> Getting Transaction hash var txnCount = web3.eth.getTransactionCount(...


3

This code will generate the same address from the mnemonic that MetaMask, MyEtherWallet, etc const bip39 = require('bip39'); const hdkey = require('ethereumjs-wallet/hdkey'); const mnemonic = 'party box feel talent peace tiger endorse defy cheese girl tumble mail'; const seed = bip39.mnemonicToSeed(mnemonic); const hdwallet = hdkey.fromMasterSeed(seed); ...


3

Well, I have finally found the answer to all of those problems, as was stated before the nonce was at fault here, except it is kind subtle. Every transaction you send with an account you are supposed to increase a nonce which is tied to the account. The best way to do it is to use : nonce = web3.eth.getTransactionCount(fromAccount); However on the ...


3

let send_add = send_public_address; let recv_add = rec_public_address; let transfer_amount = web3.toWei(data.amount, 'ether'); let nonce = web3.toHex(web3.eth.getTransactionCount(send_public_address)); var private_key = privatekey_sender.slice(2); let gas = web3.toHex(data.gas_limit); let gasPrice = web3.toHex(data.gas_price); var rawTx = { ...


3

You may want to try using the "unsign()" function in the ethereumjs-tx-sign library to inspect all the data contained in each of your raw transaction values.. and compare the contents. You may find that it comes down to fixing an oversight in properly encoding all of the input parameters used when generating the raw transaction. A missing '0x' can wreak ...


2

Yes, it's a bug on Ganache. If you look at the source code you'll see your error message. There's a function _transactionIsContractCall() defined on line 849 which returns true if the transaction has some data. Which it does. So Ganache is now thinking that you're calling a contract, so it expects something on code (the function you're calling on the ...


2

Do not use with 'Ox' Remove those in privatekey


2

The transaction is being sent to the address 0x19149798f777a3d738777334ccbf0063a04fca3b, which is not a contract. No ERC20 transfer occurs because no transaction was sent to an ERC20 token contract.


2

The transaction does not have a "to" so the EVM will try to deploy a new contract using the data field as bytecode. You are sending in the data field the following: 0xa9059cbb0000000000000000000000000764edccd0278ee60c421148b8bab812306d90d50000000000000000000000000000000000000000000000000de0b6b3a7640000 Now 0xa9 is not a valid opcode and the EVM will halt ...


2

contribute doesn't take any parameters, but you're trying to pass one. You probably instead wanted to call the function with no parameters but attach ether to the transaction: const txObject = { nonce: web3.utils.toHex(txCount), to: "xxx", gasLimit: web3.utils.toHex(41000), gasPrice: web3.utils.toHex(web3.utils.toWei("4", "gwei")), // NOTE: Drop ...


2

I see two elements that could help solving your problem: You are calling new TX(txData) instead of the recommended way new EthereumTx(txParams). Now, this might be to simple different naming of variables on your side, but sticking to the standards is often helpful in debugging. Besides, ethereumjs-tx depends on some JS ES6 capabilities, which are not ...


2

To answer the title directly, the chain_id of ganache is 0x539 (or 1337).


2

According to this issue, private blockchains are not supported by ethereumjs-tx. You have to use ethereumjs-common. So I think the problem was that, since my call to the Transaction constructor did not include a second parameter (an object specifying a chain), it probably defaulted to mainnet. But since the accounts I am working with are all on a private ...


2

You can do this way : const EthereumTx = require('ethereumjs-tx').Transaction; import Common from 'ethereumjs-common'; const customCommon = Common.forCustomChain( 'mainnet', { name: 'my-private-blockchain', networkId: NETWORK_ID, chainId: CHAIN_ID, }, 'istanbul', ); ...


2

Your gas price is too low. You can check over here for an "estimate", currently 2 gwei as I write: https://ropsten-stats.parity.io/ I imagine you mean to say 8 gwei but it is off by several orders of magnitude. This is an opportunity to learn about stuck transactions and now to resolve them which any process that sends transactions at scale should ...


2

This part was wrong. tx.sign(privateKey1) Fix it like this: tx.sign(privateKey1Buffer)


2

Hey you need to do this for testing on kovan const tx = new EthereumTx({ from: PK, chainId: 42, // kovan chain id to: "0x8631c939359FBb8cb336532b191ED80b20287CD1", value: toHex(toWei(".1")), gas: toHex("21000"), nonce, });


1

If you don't now network_id then the following network you can use check your truffle.js development: { host: '127.0.0.1', port: 8545, network_id: "*", from: "", // default address to use for any transaction Truffle makes }


1

Function totalSupply is constant (either pure or view, in this case - view). As such, it doesn't change anything on the blockchain. Therefore, is no transaction involved here whatsoever. You just need to issue a Web3-RPC (a remote procedure call to the node via Web3 protocol). And since there is no transaction involved, there is no need to sign one. ...


1

You have to encode tha call to transfer into the data field. 4 bytes function signature of transfer(address,uint256) 32 bytes address parameter right aligned filled with zero bytes on the left 32 bytes amount paramter For example if you want to transfer 0.2 DAI to 0xaaBBCcDDEeff00112233AaBbCcdDeEfF00112233. Your data field will be a9059cbb (function ...


1

The serialize function is used to convert the javascript transaction object into an RLP encoding of the transaction. The RLP encoding processes use a standard method to encodes structures/objects into bytes in a way that they can be sent and understood from one application/library to another - independent of the language they are using. In this case - the ...


1

Serialization means that the message is packed in a byte stream, which properties (like encoding, byte ordering, etc.) are defined by a common protocol. This way you can ensure everybody can pack (serialize) the object into a byte-stream and send it to any participant who knows the protocol, whereupon the participant is able to properly unpack (deserialize) ...


1

another possible cause (that was just reported) is that there may be in issue with the output generated by ethereumjs-tx when a chainId is specified. TBD..


1

I had same issue with npm install web3. but after executed command of • npm install --global --production windows-build-tools, executing npm install web3 without error but when move into node console, require('web3') gets error. finally I found npm install web3 did not download web3.js and web3.min.js. but change to use npm install ethereum/web3.js works for ...


1

You can just use Etherscan explorer. For example: You want to analyze the account 0x058251232C086247cA91998472245D8Ae213666c. 1.Search this address in Etherscan and you will get this: https://etherscan.io/address/0x058251232c086247ca91998472245d8ae213666c 2.Click "View All". 3.Find transactions with flag "Contract Creation". 4.Click the flag "Contract ...


1

Now, if we send all 3 of above off-chain tx on blockchain, it will consume similar gas as if we had send them at the time of signing the tx. How does it reduce the cost? You only send the last off-chain transaction. And if X and Y are signing a new balance status of both the party everytime then what prevents them from uploading the previously ...


Only top voted, non community-wiki answers of a minimum length are eligible