I'm using web3 1.0 beta, and I'd like to get TxId before it's mine

I find a lot answer with sendTransaction, but If I use it I get sendTransaction is not a function

My code is like this:

   from: c.defaultAccount
(valore) => {....},
(err) => {....})

In this way, from my client, I can call my function in my Smart contract. c.istanza is istanza = new web3.eth.Contract(data.abi, data.address);

If i Use something like this

            from: c.defaultAccount
            (valore) => {

            (err) => {

I have a problem sendTransaction is not a function.

How can I get TxId before it mined? I want to have this id, because I store it in Database and I can check when it's mined (it's correct to check this ?)


1 Answer 1


The documentation for send is here: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-send.

It looks like you want the transactionHash event of the return value. The example from the documentation is as follows:

// using the event emitter
myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
.on('transactionHash', function(hash){

("Transaction hash" is I assume what you mean by "TxId".)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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