Skip to content

Commit

Permalink
Fixed color issue in Smart contract Developing Demos
Browse files Browse the repository at this point in the history
  • Loading branch information
vasmohi committed Jun 27, 2024
1 parent bdf7f8a commit e5f008f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docs/quick-start/develop-your-first-aelf-smart-contract/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ This API list ensures that users can easily interact with the Bingo contract, re

1. Create a new folder named `BingoGame`:

```base
```sh
mkdir BingoGame
cd BingoGame
```

2. Execute the following commands to create and initialize the contract project:

```base
```sh
dotnet new aelf -n BingoGameContract -N AElf.Contracts.BingoGame
```

Expand All @@ -101,7 +101,7 @@ After successful execution, you will find `src` and `test` directories within t

Based on the API list from the requirements analysis, the `bingo_contract.proto` file should be defined as follows:

```base
```cs
syntax = "proto3";

import "aelf/core.proto";
Expand Down Expand Up @@ -221,7 +221,7 @@ To test the Bingo contract, follow these steps to set up the environment and wri

Ensure the following directory structure for your protobuf files:

```base
```sh
test
├── Protobuf
│ ├── message
Expand All @@ -235,7 +235,7 @@ To test the Bingo contract, you'll need to set up two stubs: one for the Bingo c

#### 2. Prepare the Stubs

```base
```cs
// Get a stub for testing.
var keyPair = SampleECKeyPairs.KeyPairs[0];
var stub = GetBingoContractStub(keyPair);
Expand All @@ -248,7 +248,7 @@ Here, `stub` is the Bingo contract stub, and `tokenStub` is the Token contract s
#### 3. Prepare the Bonus Pool
In the unit test, the keyPair account is preloaded with a large amount of ELF tokens by default. To run the Bingo contract, you'll need to transfer some ELF tokens to the Bingo contract as a bonus pool:

```base
```cs
// Prepare the bonus pool.
await tokenStub.Transfer.SendAsync(new TransferInput
{
Expand All @@ -262,7 +262,7 @@ await tokenStub.Transfer.SendAsync(new TransferInput

You can now start using the BingoGame contract by registering a player:

```base
```cs
// Register the player.
await stub.Register.SendAsync(new Empty());
```
Expand All @@ -271,7 +271,7 @@ await stub.Register.SendAsync(new Empty());

After registration, retrieve and check the player's information:

```base
```cs
// Retrieve and check player information.
var address = Address.FromPublicKey(keyPair.PublicKey);
var playerInformation = await stub.GetPlayerInformation.CallAsync(address);
Expand All @@ -283,7 +283,7 @@ playerInformation.RegisterTime.ShouldNotBeNull();

Before placing a bet, you need to approve the Bingo contract to spend tokens on behalf of the player:

```base
```cs
// Approve the Bingo contract.
await tokenStub.Approve.SendAsync(new ApproveInput
{
Expand All @@ -297,7 +297,7 @@ await tokenStub.Approve.SendAsync(new ApproveInput

Place a bet using the Play method of the Bingo contract:

```base
```cs
// Place a bet.
await stub.Play.SendAsync(new Int64Value { Value = 10000 });
```
Expand All @@ -306,7 +306,7 @@ await stub.Play.SendAsync(new Int64Value { Value = 10000 });

Verify that a Bout is generated after placing the bet:

```base
```cs
// Check if Bout is generated.
Hash playId;
var playerInformation = await stub.GetPlayerInformation.CallAsync(address);
Expand All @@ -318,7 +318,7 @@ playId = playerInformation.Bouts.First().PlayId;

Since determining the outcome requires eight blocks, send seven invalid transactions to increase the block height:

```base
```cs
// Increase block height by mining 7 more blocks.
for (var i = 0; i < 7; i++)
{
Expand All @@ -330,7 +330,7 @@ for (var i = 0; i < 7; i++)

Finally, check the award. A non-zero award indicates a win:

```base
```cs
// Check the award.
await stub.Bingo.SendAsync(playId);
var award = await stub.GetAward.CallAsync(playId);
Expand Down

0 comments on commit e5f008f

Please sign in to comment.