Receiving Payments
Explore how to update Solidity smart contracts to accept Ether payments and implement a balance retrieval function. Understand transaction handling, testing practices, and converting Ether to Wei units. This lesson guides you through writing failing tests, adding necessary contract code, and verifying successful balance updates.
We'll cover the following...
We'll cover the following...
Receive payments
We can now store addresses and split ratios inside a smart contract. Let’s update our contract so that it can also receive payments. Let’s start by writing a failing test for this:
Let’s take a look at the code above:
Lines 23–26: We use the
owner.sendTransaction()function to send Ethers the contract from theowneraccount. ...