Skip to content

dcSpark/plutus-smart-contract-upgrade-dApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plutus Upgrade Smart Contract

A smart contract which allows upgrading the smart contract of a dApp UTXO via gathering signatures.

license

Disclaimer

The code on this repository has not been audited. We don't recommend it using in production without a full security audit. Use it at your own risk!.

Protocol

This contract enables updating the treasury UTXO to a new smart contract if enough signatures are collected.

Protocol steps:

  1. Prerequisites:

    • The contract to be migrated must include the migration code and be parametrized with the treasury token.
    • The treasury must be parametrized with the authorized public signatures and the required minimum numer of them.
  2. Build the new migration datum with:

    • the current contract validator hash
    • the validator hash of the contract to migrate to
    • the new datum hash
    • the value to move to the new contract (should be the value in the current contract)
  3. Gather signatures

    • Approved signers must sign the migration datum hash (from step 1)
  4. Migrate the contract

    • To allow migration, the origin contract requires the treasury token to be spent and pay to the treasury on the same transaction
    • The treasury will allow spending the treasury token if the origin script, the target script, the new datum at the target script, and the value at the target script matches the signed datum hash.

Building

To build the project execute cabal build at the project root.

To build:

$ nix-shell
...
$ cabal build
...

Testing

To run use-case test execute the following commands at the project root.

$ cabal test
$ cabal test
Build profile: -w ghc-8.10.4.20210212 -O1
In order, the following will be built (use -v for more details):
 - contract-upgrade-0.1.0.0 (test:contract-upgrade-test) (first run)
Preprocessing test suite 'contract-upgrade-test' for contract-upgrade-0.1.0.0..
Building test suite 'contract-upgrade-test' for contract-upgrade-0.1.0.0..
Running 1 test suites...
Test suite contract-upgrade-test: RUNNING...
use cases
  Simple endpoint tests
    Expose endpoints:                OK
  Normal contract use
    Collect prize:                   OK (0.08s)
    Try prize with invalid response: OK (0.04s)
    Migrate contract:                OK (0.11s)

All 4 tests passed (0.24s)
Test suite contract-upgrade-test: PASS
1 of 1 test suites (1 of 1 test cases) passed.

About

A smart contract which allows upgrading the smart contract of a dApp UTXO via gathering signatures.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published