Skip to content

Commit

Permalink
Creating a new file for interacting with smart contract
Browse files Browse the repository at this point in the history
  • Loading branch information
AelfHarsh committed Jul 5, 2024
1 parent 1913e16 commit 1b3d9e4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_position: 3
title: Deploy and Interact with Smart Contract
description: Deploying and Interacting with smartcontract
title: Deploying Smart Contract
description: Deploying smartcontract
---

## Preparing for deployment
Expand Down Expand Up @@ -79,55 +79,3 @@ aelf-deploy -a $WALLET_ADDRESS -p $WALLET_PASSWORD -c $CONTRACT_PATH -e https://
Please wait for approximately 1 to 2 minutes. If the deployment is successful, it will provide you with the contract address.

![result](/img/deploy-result.png)

## Interact with Your Deployed Smart Contract

### Approving Smart Contract Spending

```bash
aelf-command send ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Approve
```

:::tip
ℹ️ Note: `ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx` is the contract address of `Multitoken Contract` on aelf Testnet Sidechain (tDVW).
:::

When prompted, enter the following parameters to approve the spending of 90 ELF tokens:

```terminal
Enter the params one by one, type `Enter` to skip optional param:
? Enter the required param <spender>: $CONTRACT_ADDRESS
? Enter the required param <symbol>: ELF
? Enter the required param <amount>: 9000000000
```

### Initializing Lottery Game Contract

```bash
aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Initialize
```

### Depositing funds into the Lottery Game Contract

```bash
aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Deposit
```

### Playing the Lottery Game

```bash
aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Play
```

Let's check the `balance`

```bash
aelf-command call ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io GetBalance
```

You will be prompted for the following:

```terminal
Enter the required param <symbol>: ELF
Enter the required param <owner>: $WALLET_ADDRESS
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
sidebar_position: 4
title: Interact with the Smart Contract
description: Interacting with the smartcontract
---

### Approving Smart Contract Spending

```bash
aelf-command send ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Approve
```

:::tip
ℹ️ Note: `ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx` is the contract address of `Multitoken Contract` on aelf Testnet Sidechain (tDVW).
:::

When prompted, enter the following parameters to approve the spending of 90 ELF tokens:

```terminal
Enter the params one by one, type `Enter` to skip optional param:
? Enter the required param <spender>: $CONTRACT_ADDRESS
? Enter the required param <symbol>: ELF
? Enter the required param <amount>: 9000000000
```

### Initializing Lottery Game Contract

```bash
aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Initialize
```

### Depositing funds into the Lottery Game Contract

```bash
aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Deposit
```

### Playing the Lottery Game

```bash
aelf-command send $CONTRACT_ADDRESS -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io Play
```

Let's check the `balance`

```bash
aelf-command call ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx -a $WALLET_ADDRESS -p $WALLET_PASSWORD -e https://tdvw-test-node.aelf.io GetBalance
```

You will be prompted for the following:

```terminal
Enter the required param <symbol>: ELF
Enter the required param <owner>: $WALLET_ADDRESS
```
7 changes: 5 additions & 2 deletions sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ const sidebars: SidebarsConfig = {
},
{
type: "doc",
id: "tutorials/dapp-development/lottery-game/deploy-interact-smart-contract",
id: "tutorials/dapp-development/lottery-game/deploy-smart-contract",
},
{
type: "doc",
id: "tutorials/dapp-development/lottery-game/interact-smart-contact",
},
],
},
Expand Down Expand Up @@ -351,5 +355,4 @@ const sidebars: SidebarsConfig = {
],
};


export default sidebars;

0 comments on commit 1b3d9e4

Please sign in to comment.