You're submitting an argument called amount, not a payment in Ether.
return projectBeingFunded.fund({from: account, amount:amountToGive});
That would almost be appropriate if the contract function read:
function fund(uint amount) returns(bool) {}
Would actually be:
return projectBeingFunded.fund(amountToGive, {from: account});
But it actually says no arguments are expected, and ETH is expected:
function fund() payable returns (bool) { ...
The unexpected argument is a JUMP. So, try this:
return projectBeingFunded.fund({from: account, value: amountToGive});
Where amountToGive is a uint in Wei and the sender has that much money, as I assume is the case.
Hope it helps.
Yes, the payable
keyword makes the function capable of receiving the blockchain's native asset - such as Eth or BNB. If you try to send the native asset to the contract and there is no payable
function to receive it, the transaction will revert.
All other asset types (ERC20 tokens, ERC721, ...) are perhaps, technically, not even assets at all. They are just smart contracts which keep record of who owns how many of that contract's assets - simple ledgers. Various other smart contracts then utilize those (non-)assets in various ways, but all of that functionality has to be explicitly written as contract code.
Same goes for moving the assets: the native asset has a data slot in transactions (value
) where it can be natively moved around. All other asset transfers are just transactions to various smart contracts, asking the contracts to change their ledger values.
Best Answer
You can make a transaction and send ether to the contract address
Making a transaction should call the receive function.