---
# System prepended metadata

title: 'Walk Through of [Marigold Training 4](https://github.com/marigold-dev/training-dapp-4)'

---

---
title: Walk Through of [Marigold Training 4](https://github.com/marigold-dev/training-dapp-4)
author: Michael Kernaghan
---
# Walk Through of [Marigold Training 4](https://github.com/marigold-dev/training-dapp-4)

# Training dapp n°4 - ☝️ Upgradable Poke game

## 📝 Prerequisites 
Use previous demo results code

## 🔃 Upgrades 

### 😵 Naive approach

### Stored Lambda function ⭐
✅ taq compile pokeGame.jsligo

✅ taq deploy pokeGame.tz -e testing
```
┌─────────────┬──────────────────────────────────────┬──────────┬─────────────┐
│ Contract    │ Address                              │ Alias    │ Destination │
├─────────────┼──────────────────────────────────────┼──────────┼─────────────┤
│ pokeGame.tz │ KT1NNmpuVCZYNQ9eFFNSRecuzxtvb8Zqx1Fk │ pokeGame │ ghostnet    │
└─────────────┴──────────────────────────────────────┴──────────┴─────────────┘
```
✅ taq generate types ./app/src
cd app
yarn run start

When you restart the server there are compilation errors:

Demo notes
>Note : like in previous training, export the Storage type on ./app/src/pokeGame.types.ts like this export type Storage = { Bug : on taqueria version <= v0.19.3, lambda type are not supported. add the type manually on ./app/src/pokeGame.types.ts like this type lambda = (oracleAddress : address) => string; and remove the wrong import lambda from './type-aliases'

So change ./app/src/pokeGame.types.ts from
![](https://i.imgur.com/uA91WX0.png)

to
![](https://i.imgur.com/lOxn3XA.png)

✅ taq create contract pokeGame.parameters.jsligo

✅ taq compile pokeGame.jsligo 
✅ taq call pokeGame --param pokeGame.parameter.default_parameter.tz -e testing
```
┌────────────────┬──────────────────────────────────────┬──────────────┬──────────────────────────────────────────────────┬────────────┬────────────────────────────────┐
│ Contract Alias │ Contract Address                     │ Tez Transfer │ Parameter                                        │ Entrypoint │ Destination                    │
├────────────────┼──────────────────────────────────────┼──────────────┼──────────────────────────────────────────────────┼────────────┼────────────────────────────────┤
│ pokeGame       │ KT1LRznPG4W99BF2KBd8mrkS4RaW8hjLbwWV │ 0            │ (Right (Right { DROP ; PUSH string "YEAH!!!" })) │ default    │ https://ghostnet.ecadinfra.com │
│                │                                      │              │                                                  │            │                                │
└────────────────┴──────────────────────────────────────┴──────────────┴──────────────────────────────────────────────────┴────────────┴────────────────────────────────┘
```
There is no taq call equivalent in VSCode extensions

![](https://i.imgur.com/ibKXlVf.png)

To fix, 
✅ taq stop sandbox local
✅ taq start sandbox local

### Proxy pattern ⭐⭐
✅ taq create contract tzip18.jsligo

✅ taq compile pokeGame.jsligo
```
┌──────────────────────────┬───────────────────────────────────────┐
│ Contract                 │ Artifact                              │
├──────────────────────────┼───────────────────────────────────────┤
│ pokeGame.jsligo          │ artifacts/pokeGame.tz                 │
├──────────────────────────┼───────────────────────────────────────┤
│ pokeGame.storages.jsligo │ artifacts/pokeGame.default_storage.tz │
└──────────────────────────┴───────────────────────────────────────┘
```
✅ taq create contract proxy.jsligo
✅ taq compile proxy.jsligo
```
┌──────────────┬────────────────────┐
│ Contract     │ Artifact           │
├──────────────┼────────────────────┤
│ proxy.jsligo │ artifacts/proxy.tz │
└──────────────┴────────────────────┘
```
✅ taq create contract proxy.storages.jsligo

✅ taq compile proxy.jsligo 
✅ taq deploy proxy.tz -e testing
```
┌──────────┬──────────────────────────────────────┬───────┬─────────────┐
│ Contract │ Address                              │ Alias │ Destination │
├──────────┼──────────────────────────────────────┼───────┼─────────────┤
│ proxy.tz │ KT1CEYeFCUTugBf7wVq37P3bAcwbs7dvb2g2 │ proxy │ ghostnet    │
└──────────┴──────────────────────────────────────┴───────┴─────────────┘
```
Change with the address on file pokeGame.storages.jsligo

✅ taq compile pokeGame.jsligo
✅ taq deploy pokeGame.tz -e testing
```
┌─────────────┬──────────────────────────────────────┬──────────┬─────────────┐
│ Contract    │ Address                              │ Alias    │ Destination │
├─────────────┼──────────────────────────────────────┼──────────┼─────────────┤
│ pokeGame.tz │ KT1MVp7ZTHGoBYkcgMFATb7EoTPgnDsi9VZP │ pokeGame │ ghostnet    │
└─────────────┴──────────────────────────────────────┴──────────┴─────────────┘
```
✅ taq create contract proxy.parameters.jsligo
✅ taq compile proxy.jsligo
```
┌─────────────────────────┬──────────────────────────────────────────────┐
│ Contract                │ Artifact                                     │
├─────────────────────────┼──────────────────────────────────────────────┤
│ proxy.jsligo            │ artifacts/proxy.tz                           │
├─────────────────────────┼──────────────────────────────────────────────┤
│ proxy.storages.jsligo   │ artifacts/proxy.default_storage.tz           │
├─────────────────────────┼──────────────────────────────────────────────┤
│ proxy.parameters.jsligo │ artifacts/proxy.parameter.initProxyWithV1.tz │
└─────────────────────────┴──────────────────────────────────────────────┘
```
✅ taq call proxy --param proxy.parameter.initProxyWithV1.tz -e testing
```
┌────────────────┬──────────────────────────────────────┬──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┬─────────────────────────────────────┐
│ Contract Alias │ Contract Address                     │ Tez Transfer │ Parameter                                                                                              │ Entrypoint │ Destination                         │
├────────────────┼──────────────────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┼─────────────────────────────────────┤
│ proxy          │ KT1CEYeFCUTugBf7wVq37P3bAcwbs7dvb2g2 │ 0            │ (Right                                                                                                 │ default    │ https://ghostnet.tezos.marigold.dev │
│                │                                      │              │    (Pair { Pair (Pair (Some (Pair "KT1XJ3HaQ8khTjLmvAKxzEiHNasZiSwA8LJ7" "Poke")) False) "Poke" ;      │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1XJ3HaQ8khTjLmvAKxzEiHNasZiSwA8LJ7" "PokeAndGetFeedback")) False) │            │                                     │
│                │                                      │              │                 "PokeAndGetFeedback" ;                                                                 │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1XJ3HaQ8khTjLmvAKxzEiHNasZiSwA8LJ7" "Init")) False) "Init" ;      │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1XJ3HaQ8khTjLmvAKxzEiHNasZiSwA8LJ7" "changeVersion")) False)      │            │                                     │
│                │                                      │              │                 "changeVersion" ;                                                                      │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1XJ3HaQ8khTjLmvAKxzEiHNasZiSwA8LJ7" "feedback")) False)           │            │                                     │
│                │                                      │              │                 "feedback" }                                                                           │            │                                     │
│                │                                      │              │          None))                                                                                        │            │                                     │
│                │                                      │              │                                                                                                        │            │                                     │
└────────────────┴──────────────────────────────────────┴──────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────┴─────────────────────────────────────┘
```
#### Lets' go to the frontend
Note : don't forget to export Storage type like in previous training:
>⚠️ Note : we will need to use Storage type on the frontend side, by default, taquito does not export it. Export the type on the file pokeGame.types.ts adding a keywork export as it : export type Storage = { ...

✅ taq compile pokeGame.jsligo 
✅ taq compile proxy.jsligo 
❓taq generate types ./app/src1

The types generate ok, but the output includes:
```
...
Processing /proxy.parameter.initProxyWithV1.tz...
Unknown method: pair {
  node: {
    prim: 'pair',
    args: [ [Object], [Object] ],
    [Symbol(source_reference)]: { first: 12, last: 60 }
  },
  args: [
    {
      prim: 'string',
      annots: [Array],
      [Symbol(source_reference)]: [Object]
    },
    {
      prim: 'bytes',
      annots: [Array],
      [Symbol(source_reference)]: [Object]
    }
  ]
}
...
```
You can do all the same actions as before through the proxy.

❌1. Login
👉 the local site never comes up on :3000
2. Refresh the contract list
3. Mint 1 ticket
4. Wait for confirmation popup
5. Poke
6. Wait for confirmation popup
7. Refresh the contract list

#### Let's deploy a new contract V2 and test it again.

✅ taq compile pokeGame.jsligo
✅ taq deploy pokeGame.tz -e testing --storage pokeGame.storage.storageV2.tz
```
┌─────────────┬──────────────────────────────────────┬──────────┬─────────────┐
│ Contract    │ Address                              │ Alias    │ Destination │
├─────────────┼──────────────────────────────────────┼──────────┼─────────────┤
│ pokeGame.tz │ KT1GfY3MVM5tStetD7re8XWHSJbodHPJ1qrV │ pokeGame │ ghostnet    │
└─────────────┴──────────────────────────────────────┴──────────┴─────────────┘
```
✅ taq compile proxy.jsligo 
✅ taq call proxy --param proxy.parameter.initProxyWithV2.tz -e testing
```
┌────────────────┬──────────────────────────────────────┬──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┬─────────────────────────────────────┐
│ Contract Alias │ Contract Address                     │ Tez Transfer │ Parameter                                                                                              │ Entrypoint │ Destination                         │
├────────────────┼──────────────────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┼─────────────────────────────────────┤
│ proxy          │ KT1CEYeFCUTugBf7wVq37P3bAcwbs7dvb2g2 │ 0            │ (Right                                                                                                 │ default    │ https://ghostnet.tezos.marigold.dev │
│                │                                      │              │    (Pair { Pair (Pair (Some (Pair "KT1AxZbF6hoXHGWZjcAn4MzLDRsVYgZGDmCL" "Poke")) False) "Poke" ;      │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1AxZbF6hoXHGWZjcAn4MzLDRsVYgZGDmCL" "PokeAndGetFeedback")) False) │            │                                     │
│                │                                      │              │                 "PokeAndGetFeedback" ;                                                                 │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1AxZbF6hoXHGWZjcAn4MzLDRsVYgZGDmCL" "Init")) False) "Init" ;      │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1AxZbF6hoXHGWZjcAn4MzLDRsVYgZGDmCL" "changeVersion")) False)      │            │                                     │
│                │                                      │              │                 "changeVersion" ;                                                                      │            │                                     │
│                │                                      │              │            Pair (Pair (Some (Pair "KT1AxZbF6hoXHGWZjcAn4MzLDRsVYgZGDmCL" "feedback")) False)           │            │                                     │
│                │                                      │              │                 "feedback" }                                                                           │            │                                     │
│                │                                      │              │          None))                                                                                        │            │                                     │
│                │                                      │              │                                                                                                        │            │                                     │
└────────────────┴──────────────────────────────────────┴──────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────┴─────────────────────────────────────┘
```

Back to the web app, test the flow again :

👉 the local site never comes up on :3000
1. Refresh the contract list
2. Mint 1 ticket
3. Wait for confirmation popup
4. Poke
5. Wait for confirmation popup
6. Refresh the contract list

#### Last part is to set the old smart contract as obsolete

✅ taq compile proxy.jsligo 
❓ taq call proxy --param proxy.parameter.changeVersionV1ToV2.tz -e testing

👉 I don't see in the instructions that artifacts/proxy.parameter.changeVersionV1ToV2.tz is created, or what code it should have. Did I miss it?

✅ Check on an indexer that the V1 storage.tzip18.contractNext is pointing to the next version address V2 : https://ghostnet.tzkt.io/KT1MVp7ZTHGoBYkcgMFATb7EoTPgnDsi9VZP/storage/

![](https://i.imgur.com/2T5Hi4C.png)

# End

[Beyond the End](https://github.com/michaelkernaghan?tab=repositories)