You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
Given a contract with a very simple payable function, when I try to sendTransaction from ganache account with more than sufficient gas to the Contract, I get the following error:
VM Exception while processing transaction: revert
I tried to send with a large gas as well as with the estimated one (around 21046), but the error still exists.
Steps to Reproduce
truffle init
Create the following contract under ./contracts
Test.sol
pragma solidity 0.5.8;
contract Test {
function deposit() public payable {}
}
Create the following migration under ./migrations
2_deploy_contract.js
const Test = artifacts.require("Test");
module.exports = function(deployer) {
deployer.deploy(Test);
};
Hm. Looks like there's a mismatch between your contract and the way you're sending transactions.
If you just do a regular sendTransaction, it's going to invoke the "fallback function". If you change your deposit function to be this fallback function, you shouldn't see the revert:
pragma solidity0.5.8;
contractTest {
function () publicpayable {}
}
Alternatively, if you want to keep the name deposit, you can invoke this function in JS as follows (using truffle-contract syntax):
Issue
Given a contract with a very simple
payable
function, when I try tosendTransaction
from ganache account with more than sufficient gas to the Contract, I get the following error:I tried to send with a large gas as well as with the estimated one (around 21046), but the error still exists.
Steps to Reproduce
truffle init
./contracts
Test.sol
./migrations
2_deploy_contract.js
$ truffle develop
$ migrate
Expected Behavior
I expect the transaction should go through successfully and the Ether should be transferred to the contract.
Actual Results
Received the error
Environment
The text was updated successfully, but these errors were encountered: