Skip to content

Commit

Permalink
Merge pull request #2574 from ethereum/docs-udapp-fb-rec
Browse files Browse the repository at this point in the history
updating docs with about Low level interactions with a contract
  • Loading branch information
yann300 authored Feb 6, 2020
2 parents 4e74bdb + 425f7ca commit 12039f0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
Binary file modified docs/images/a-jvm-calling-instance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/a-receive-fun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/a-udapp1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/a-udapp2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 26 additions & 3 deletions docs/udapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The deployed contract appears but is in its collapsed form.

Click the sideways caret to open it up.

![](images/a-debug3-udapp2.png)
![](images/a-udapp1.png)

You will see the functions in the contract. The functions buttons can have different color buttons.

Expand All @@ -24,8 +24,8 @@ You will see the functions in the contract. The functions buttons can have diff
![](images/a-jvm-calling-instance.png)


For more information see more about [Solidity
modifier](http://solidity.readthedocs.io/en/develop/miscellaneous.html?highlight=pure#modifiers)
See more information about [Solidity
modifiers](http://solidity.readthedocs.io/en/develop/miscellaneous.html?highlight=pure#modifiers) in the Solidity docs.
.

If a function requires input parameters, well.. you gotta put them in.
Expand Down Expand Up @@ -55,6 +55,29 @@ Clicking the clipboard icon will encode the inputs and will copy them. Only a v

So if you made a mistake and put a uint8 where an address should have been, clicking the clipboard here will give you an error.

## Low level interactions

Low level interactions are used to send funds or calldata or funds & calldata to a contract through the **recieve()** or **fallback()** function. Typically, you should only need to implement the fallback function if you are following an upgrade or proxy pattern.

The low level interactions section is below the functions in each deployed contract.

![](images/a-udapp1.png)


Please note the following:

- If you are executing a plain Ether transfer to a contract, you need to have the receive() function in your contract. If your contract has been deployed and you want to send it funds, you would input the amount of Ether or Wei etc. (see **A** in graphic below), and then input **NOTHING** in the calldata field of **Low level interactions** (see **B** in graphic) and click the Transact button (see **C** in graphic below).

![](images/a-receive-fun.png)

- If you are sending calldata to your contract with Ether, then you need to use the fallback() function and have it with the state mutability of **payable**.

- If you are not sending ether to the contract but **are** sending call data then you need to use the fallback() function.

- If you break the rules when using the **Low level interactions** you will be slapped with a warning.

Please see the [solidity docs](https://solidity.readthedocs.io/en/latest/contracts.html#receive-ether-function ) for more specifics about using the **fallback** and **receive** functions.

### Passing in a tuple or a struct to a function
To pass a tuple in, you need to put in an an array [].

Expand Down

0 comments on commit 12039f0

Please sign in to comment.