Unable to test a smart contract function with payable modifier

Hey all,

I am trying to write some tests for an upgradable contract I am writing. No problem on the contract end but some problems writing tests in waffle/ ether.js that is compatible with the contract. Simply put I have a function in solidity that takes one parameters as well as has the modifier "payable" simply. I am trying to to find the syntax for send eth during a function called w/ Waffle / ether.js. I've been reading around and have no luck. Any thoughts. For context, I remember reading somewhere that there was a bug send eth to a empty smart contract address with upgradable contracts and thought that might be the problem. Hence why I am posting here. Any advice thought would be greatly appreciated. Thank you!

https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend use the overrides param.

More specifically, you should use the overrides.value params. So include an object { value: 1000 } as the last argument to your function call.

1 Like