I've seen this in Solidity several times, but I can't find it in the documentation nor do I know how to describe it in a search engine. Say you have a function:
function buyItem(uint256 _upc)
public
payable
// Call modifier to check if upc has passed previous supply chain stage
forSale(_upc)
// Call modifer to check if buyer has paid enough
paidEnough(items[_upc].productPrice)
// Call modifer to send any excess ether back to buyer
checkValue(_upc)
{
// Update the appropriate fields - ownerID, distributorID, itemState
items[_upc].ownerID = msg.sender;
items[_upc].distributorID = msg.sender;
items[_upc].itemState = State.Sold;
// Transfer money to farmer
items[_upc].distributorID.transfer(items[_upc].productPrice);
// emit the appropriate event
emit Sold(_upc);
}
When you call the function in the test, you pass it an object with a from and value property. How do I know when I need to use these properties and where is this described in the documentation?
// Mark an item as Sold by calling function buyItem()
await supplyChain.buyItem(upc, {
from: distributorID,
value: productPrice,
});