Skip to main content

No need to set the data manually. You can use the web3 contract methods function. In your case, you can call the setValue(123,'ABC') like this:

myContract = new web3.eth.Contract(abi,contractAddress);
myContract.methods.setValue(123,'ABC')
.send({
     from: youraccount.address,
     to: myContract.options.address,
     value: 0, // Don't send ETH, this is a contract transaction
})

See the web3 docs for more information.

Keep in mind that this is not a "call". Your function changes the state of the smart contract. You can use methods.myMethod.call for executing EVM functions that do not create a transaction.

P.S: I don't want to use Metamask. I am using my account directly in my javascript code.

No need to set the data manually. You can use the web3 contract methods function. In your case, you can call the setValue(123,'ABC') like this:

myContract = new web3.eth.Contract(abi,contractAddress);
myContract.methods.setValue(123,'ABC')
.send({
     from: youraccount.address,
     to: myContract.options.address,
     value: 0, // Don't send ETH, this is a contract transaction
})

See the web3 docs for more information.

Keep in mind that this is not a "call". Your function changes the state of the smart contract. You can use methods.myMethod.call for executing EVM functions that do not create a transaction.

No need to set the data manually. You can use the web3 contract methods function. In your case, you can call the setValue(123,'ABC') like this:

myContract = new web3.eth.Contract(abi,contractAddress);
myContract.methods.setValue(123,'ABC')
.send({
     from: youraccount.address,
     to: myContract.options.address,
     value: 0, // Don't send ETH, this is a contract transaction
})

See the web3 docs for more information.

Keep in mind that this is not a "call". Your function changes the state of the smart contract. You can use methods.myMethod.call for executing EVM functions that do not create a transaction.

P.S: I don't want to use Metamask. I am using my account directly in my javascript code.

Post Undeleted by hurb
Post Deleted by hurb
Source Link
hurb
  • 391
  • 3
  • 10

No need to set the data manually. You can use the web3 contract methods function. In your case, you can call the setValue(123,'ABC') like this:

myContract = new web3.eth.Contract(abi,contractAddress);
myContract.methods.setValue(123,'ABC')
.send({
     from: youraccount.address,
     to: myContract.options.address,
     value: 0, // Don't send ETH, this is a contract transaction
})

See the web3 docs for more information.

Keep in mind that this is not a "call". Your function changes the state of the smart contract. You can use methods.myMethod.call for executing EVM functions that do not create a transaction.