Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ryestew committed Sep 2, 2020
1 parent 20b8f5d commit 2000adb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Web3Client/1_Using_Web3/Running_a_script.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Querying the Blockchain
## Querying the Blockchain

In this tutorial, we'll run a script that queries the blockchain using a JavaScript library.

Expand All @@ -10,12 +10,12 @@ Let's begin with a simple web3.js example, queryBlockNum.js.

The script's call to web3.js is wrapped in a self-executing async function that contains a try/catch block.

We'll query the current blocknumber by doing:
We'll query the current blocknumber with:
`let blockNumber = await web3.eth.getBlockNumber()`

Note that the object `web3` is injected by Remix. For more info on web3.js, check their docs, <a href="https://web3js.readthedocs.io/en/latest" target="_blank">https://web3js.readthedocs.io/en/latest</a>.
Note that the object `web3` is injected by Remix. For more info on web3.js, check their docs, <a href="https://web3js.readthedocs.io/" target="_blank">https://web3js.readthedocs.io</a>.

To use web3.js or ethers.js, you need to select the Injected Web3 or Web3 Provider environments in the **Deploy & Run** module. Scripts don't currently work with the JSVM. **If you try you'll get an error.**
To use web3.js or ethers.js, you need to select the **Injected Web3** or **Web3 Provider** environment in the **Deploy & Run** module. Scripts don't currently work with the JSVM. **If you try, you'll get an error.**

So for this example choose **Injected Web3** in the Deploy & Run module and have Metamask installed.

Expand Down
6 changes: 3 additions & 3 deletions Web3Client/2_Querying_a_Contract/queryContract.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Now that we know how to query simple data, let's try a more complex query.

This is a contract deployed to the mainnet. <a href="contract address https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code" target="_blank">contract address https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code</a>
This is a contract deployed to the mainnet - at this address: <a href="https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code" target="_blank">https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code</a>

We are going to query the contract to find the name of it's token.

The **name** variable is a state variable of the contract.

To access this **mainnet** contract we need to do some setup.
To access this **mainnet** contract, we need to do some setup.
1. Switch to the mainnet in metamask.
2. You'll probably need to refresh Remix.
3. As a result of the refresh, you may need to reload this tutorial too.
Expand All @@ -18,4 +18,4 @@ In the script, queryContract.js, we need to instantiate a new instance of web3.e
In etherscan, we can see that its name is **TetherToken**. Scrolling down to the TetherToken contract in the source code section of etherscan, we can see the state variables for the contract - the first of which is named **name**.

There are a few syntactic hoops to jump through to return the value of the state variable.
- To call the autogenerated getter function of the public state variable you need to both treat the variable as a funtion (by adding parentheses) and also tacking on a call().
- To call the autogenerated getter function of the public state variable, you need to both treat the variable as a function (by adding parentheses) and also to tack on a call().
4 changes: 1 addition & 3 deletions Web3Client/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Web3.js

This workshop is about using the web3.js to interact with a contract and more generally to the blockchain
This workshop is about using the web3.js to interact with a contract and more generally to the blockchain.

0 comments on commit 2000adb

Please sign in to comment.