From a4c3f8db8afd042ee7561e543936d8318bdb2e6c Mon Sep 17 00:00:00 2001 From: xalava Date: Tue, 24 Jan 2023 13:23:45 +0100 Subject: [PATCH] adapted subjects to recent test changes --- subjects/blockchain/basic-swap/README.md | 6 +++--- subjects/blockchain/eventful-token/README.md | 12 ++++++++---- subjects/blockchain/{lineup => line-up}/README.md | 0 subjects/blockchain/local-node/README.md | 6 ++++-- subjects/blockchain/named-festival/README.md | 1 + subjects/blockchain/read-secret/README.md | 8 ++++++-- subjects/blockchain/register-with-events/README.md | 2 ++ subjects/blockchain/transfers-history/README.md | 8 ++++---- 8 files changed, 28 insertions(+), 15 deletions(-) rename subjects/blockchain/{lineup => line-up}/README.md (100%) diff --git a/subjects/blockchain/basic-swap/README.md b/subjects/blockchain/basic-swap/README.md index 9a0a8b28..ccb40317 100644 --- a/subjects/blockchain/basic-swap/README.md +++ b/subjects/blockchain/basic-swap/README.md @@ -4,13 +4,13 @@ We will create a basic swap smart contract that will allow two users, Alice and ### Instructions -- Create a `usableToken` contract as defined before +- Create a `UsableToken` contract as defined before - Create a Smart Contract `BasicSwap` with a constructor that takes the address of two Externally Owned Accounts. -- Create a function `swap(tokenA, AmountA, TokenB, AmountB)` that takes as parameters, two `MinimalTokenAllowance`contracts and amounts +- Create a function `swap(tokenA, AmountA, TokenB, AmountB)` that takes as parameters, two `UsableToken`contracts and amounts - The function checks that users gave the corresponding allowances to the smart contract - The function proceed to transfert the first amount in TokenA from Alice to Bob and the second amount from Bob to Alice -To test your smart contract, you will need to deploy two instances of `MinimalTokenAllowance` +To test your smart contract, you will need to deploy two instances of `UsableToken` ### Resources diff --git a/subjects/blockchain/eventful-token/README.md b/subjects/blockchain/eventful-token/README.md index 763bba1f..9d7a3392 100644 --- a/subjects/blockchain/eventful-token/README.md +++ b/subjects/blockchain/eventful-token/README.md @@ -2,10 +2,14 @@ ### Instructions -- Create a Smart Conctract named `eventfulToken` -- Like MinimalToken, its constructor takes as parameter an amount that is given initially to the deployer. -- Create an event `Transfer(address, address, uint)` that returns the address from which the funds where transferred (the variable should be called `sender`), the address of the `recipient` and the `amount` of the transfer. Trigger the event within the transfer function -- Create an event `Minting(address, amount)` that returns the `address` `recipient` to which token were minted and the `amount` of tokens created. Trigger the event when appropriate. +- Create a Smart Conctract named `EventfulToken` +- Like MinimalToken, its constructor takes as parameter an amount that is given initially to the deployer. +- Create an event `Transfer(address indexed , address indexed, uint)` that returns the address from which the funds where transferred (the variable should be called `sender`), the address of the `recipient` and the `amount` of the transfer. Trigger the event within the transfer function. N +- Create an event `Minting(address, amount)` that returns the `address` `recipient` to which token were minted and the `amount` of tokens created. Trigger the event when appropriate. + +### Hint + +The `indexed` keyword will facilitate the filtering by this field of the event in later exercises. ### Notions diff --git a/subjects/blockchain/lineup/README.md b/subjects/blockchain/line-up/README.md similarity index 100% rename from subjects/blockchain/lineup/README.md rename to subjects/blockchain/line-up/README.md diff --git a/subjects/blockchain/local-node/README.md b/subjects/blockchain/local-node/README.md index f9d93962..37c1487f 100644 --- a/subjects/blockchain/local-node/README.md +++ b/subjects/blockchain/local-node/README.md @@ -15,14 +15,14 @@ Launch a local test node. You can use any client (geth, openEthereum...), but I **hardhat node** -```sh +```shell npm i hardhat npx hardhat node ``` **ganache** -``` +```shell npm i ganache-cli npx ganache-cli ``` @@ -31,6 +31,8 @@ npx ganache-cli Noticeably, local javascript nodes are not connected to any network and provide already 10 account populated with test ether. +This quest self validate with an empty "local-node.js" file + ### Notions - [hardhat](https://hardhat.org) diff --git a/subjects/blockchain/named-festival/README.md b/subjects/blockchain/named-festival/README.md index edabaac1..799d18e7 100644 --- a/subjects/blockchain/named-festival/README.md +++ b/subjects/blockchain/named-festival/README.md @@ -19,6 +19,7 @@ pragma solidity ^0.8.4; ``` - Then create a Smart Contract named `NamedFestival`. +- NB: The file name of the contract must be in kebab-case `named-festival.sol`, while contracts names are in PascalCase by convention - Create a public function `setName()` that takes a string as parameter and sets the name of the festival - Finally a function `getName()` takes no parameters and retrieves the name diff --git a/subjects/blockchain/read-secret/README.md b/subjects/blockchain/read-secret/README.md index 13dcdc49..031d83b8 100644 --- a/subjects/blockchain/read-secret/README.md +++ b/subjects/blockchain/read-secret/README.md @@ -2,9 +2,9 @@ ### Instructions -Create a web page, `readSecret.html` that loads an ethereum library, connects to ethereum testnet `kovan` and displays a secret contained in a smart contract. +Create a web page, `read-secret.html` that loads an ethereum library, connects to ethereum testnet `Sepolia` and displays a secret contained in a smart contract. -The smart contract is available at the address `0x27c8dda37a22a29cb78320bf5e1c81ca087b2f8e` on Kovan testnet. It contains one function `getSecret()` that returns a string. +The smart contract is available at the address `0x467782A5ab90af6baA6f8af0b4E69A7Ddb197fF0` on Sepolia testnet. It contains one function `getSecret()` that returns a string. You might use the following interface : @@ -12,6 +12,10 @@ You might use the following interface : const abi = ["function getSecret() view returns (string)"]; ``` +⚠️ As the test does not reach the internet: +- Store in a hardcoded manner the result in an element with `storedSecret` as id. +- Detect when internet is not available and skip the connection to the provider. + ### Notions - [ethers contract](https://docs.ethers.io/v5/api/contract/contract/) diff --git a/subjects/blockchain/register-with-events/README.md b/subjects/blockchain/register-with-events/README.md index 16a1e5c9..7f4bc641 100644 --- a/subjects/blockchain/register-with-events/README.md +++ b/subjects/blockchain/register-with-events/README.md @@ -11,6 +11,8 @@ Write solidity smart contract `RegisterWithEvents` that provides: - The functions `addDocument()` and `getDate()` as specified in the prior exercise. - An event `event DocumentAdded(bytes32, uint)` that triggers when a new document is added to the register +As in prior exercises, the file must be named register-with-events.sol while the contract is named RegisterWithEvents. + ### Notions - [Events](https://docs.soliditylang.org/en/v0.8.4/contracts.html#events) diff --git a/subjects/blockchain/transfers-history/README.md b/subjects/blockchain/transfers-history/README.md index 8cb5ba72..14c5faef 100644 --- a/subjects/blockchain/transfers-history/README.md +++ b/subjects/blockchain/transfers-history/README.md @@ -2,23 +2,23 @@ ### Instructions -- Create a JavaScript file `transfersHistory.js`that exports the function `transfersHistory(address, address)` that takes as parameters the address of a MinimalTokenEvent Smart Contract instance and the address of an user. +- Create a JavaScript file `transfersHistory.js`that exports the function `transfersHistory(address, address)` that takes as parameters the address of a `EventfulToken` Smart Contract instance and the address of an user. -It returns an array with all the transfers from that account, starting from the most recent, positive if it is toward the user, and negative if it is outside. +The function will connect to a local node and retrieve the events. It returns an array with all the transfers from that account, starting from the most recent, positive if it is toward the user, and negative if it is outside. #### Structure ```js const { ethers } = require("ethers"); -async function transfersHistory(contractAddress, userAddress) {} +async function transfersHistory(contractAddress, userAddress) {...} exports.transfersHistory = transfersHistory; ``` #### Usage ```js -const { transfersHistory } = require("./transfersHistory.sl.js"); +const { transfersHistory } = require("./transfersHistory.js"); transfersHistory( "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc",