You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wallet/how-to/use-non-evm-networks/starknet/create-a-simple-starknet-dapp.md
+10-14Lines changed: 10 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,15 +232,15 @@ export default App
232
232
233
233
## 3. Display the balance and transfer an ERC-20 token
234
234
235
-
Now that you have set up the basics, let's go a step further and show how to display the balance of a specific ERC-20 token, such as STRK, and perform a transfer using the `WalletAccount` instance.
235
+
After completing the basic setup, you can demonstrate how to display the balance of a specific ERC-20 token, for example STRK, and perform a transfer using the `WalletAccount` instance.
236
236
237
-
### 3.1. Setting Up the Contract
237
+
### 3.1. Set up the contract
238
238
239
-
To interact with an ERC-20 contract, you'll need to create a contract instance from `starknet.js` using the `WalletAccount` instance. Assuming the ABI is loaded from a JSON file, here's how you would do it:
239
+
To interact with an ERC-20 contract, you'll need to create a contract instance from `starknet.js` using the `WalletAccount` instance. Assuming the ABI (application binary interface) is loaded from a JSON file, the following code example demonstrates how to implement it:
240
240
241
241
```typescript
242
242
import { Contract } from"starknet";
243
-
importerc20Abifrom"./erc20Abi.json";// Assuming ABI is stored in this JSON file
To transfer tokens, populate the `transfer` method call and then execute the transaction using the `WalletAccount`. Here"s how you can do that:
261
+
To transfer tokens, us the `transfer` method call and then execute the transaction using the `WalletAccount`:
262
262
263
263
```typescript
264
264
import { Call } from"starknet";
@@ -335,18 +335,14 @@ function TokenBalanceAndTransfer({ walletAccount, tokenAddress }) {
335
335
}
336
336
```
337
337
338
-
### 3.5. ABI and contract address
339
-
340
-
The ABI (Application Binary Interface) for the ERC-20 contract can be found on the Voyager Explorer.
341
-
342
-
The contract address for STRK (an ERC-20 token) on Sepolia testnet is `0x049D36570D4e46f48e99674bd3fcc84644DdD6b96F7C741B1562B82f9e004dC7`.
343
-
344
338
## Next steps
345
339
346
-
In this section, we've shown how to extend your dapp by displaying the balance of an ERC-20 token like ETH and performing a token transfer. By creating a Contract instance with the WalletAccount, you can easily interact with smart contracts, fetch token balances, and execute transactions, enabling more complex functionality in your dapp.
340
+
You've set up a basic Starknet dApp and successfully added features to display an ERC-20 token balance and perform token transfers. Creating a contract instance using `WalletAccount` allows you to interact with smart contracts, retrieve token balances, and execute transactions, enabling more advanced functionality in your dapp.
341
+
342
+
Now that you have configured your dapp, you can now manage your [accounts](../manage-starknet-accounts) and networks(../manage-starknet-networks), and explore interaction methods in the [API documentation](../../../reference/non-evm-apis/starknet-snap-api.md).
347
343
348
344
## Additional resources
349
345
346
+
-[`get-starknet` official GitHub](https://github.com/starknet-io/get-starknet)
350
347
-[Use `get-starknet` to connect to a wallet and create an account instance](https://starknetjs.com/docs/guides/walletAccount)
351
348
-[Use account instance to show ERC20 balance and transfer](https://starknetjs.com/docs/guides/use_ERC20)
352
-
-[get-starknet official GitHub](https://github.com/starknet-io/get-starknet)
0 commit comments