Ethereum - Interacting with the Contract


When you click the deployed contract, you will see the various public methods provided by the contract. This is shown in the screenshot below.

Deploy Public Methods

The first method send contains an edit box in front of it. Here, you will type the parameters required by the contract method. The other two methods do not take any parameters.

Sending Money

Now, enter some amount such as 100 in front of the send function seen in the contract window. Click the send button. This will execute the contract send method, reducing the value of the contract value field and increasing the value of the amount field.

Sending Money

Examining Contract Value

The previous send money action has reduced the contract value by 100. You can now examine this by invoking the getBalance method of the contract. You will see the output when you click on the getBalance button as shown in the screenshot below −

Examining Contract Value

The contract value is now reduced to 900.

Examining Collected Amount

In this section, we will examine the amount of money collected so far on this contract. For this, click on the getAmount button. The following screen will appear.

Examining Collected Amount

The amount field value has changed from 0 to 100.

Try a few send operations and examine the contract value and the amount fields to conclude that the deployed contract is executing as expected.

Advertisements