-
Notifications
You must be signed in to change notification settings - Fork 2
Update all submodules, related fixes and mint automatization #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 32 commits
701c6c5
7cb4fe9
18b272d
04e02d1
660e936
3ed0664
60c6a99
514a0bf
167f300
fa4937d
6ad09dd
8208690
992cfa4
bb4da7a
6d8fce3
d81ca27
b94bbf0
e69e4b9
617f0df
a33db0a
1b305e1
e1ec944
16e90e3
b8a5e1c
3ace383
b1a80ed
b92239e
f8db84b
48923cd
3ec2e9d
961ef55
dfaedae
3398d17
dde76dc
1dfe8ea
43dad7d
fcae789
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,6 @@ | |
| [submodule "plutus-use-cases"] | ||
| path = plutus-use-cases | ||
| url = https://github.com/mlabs-haskell/plutus-use-cases | ||
| [submodule "seabug-contracts"] | ||
| path = seabug-contracts | ||
| url = [email protected]:mlabs-haskell/seabug-contracts.git | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,73 +69,85 @@ Ensure that Nami is set to Testnet, that you have some Test Ada, and that you've | |
|
|
||
| ### Optional: Mint your own NFTs | ||
|
|
||
| This process will be simplified in the future. | ||
| UPDATE: see the minting section in `seabug-contracts/README.md` instead. The following minting process is currently broken, see [\#22](https://github.com/mlabs-haskell/seabug/issues/22). | ||
|
|
||
| #### Start plutus-chain-index | ||
|
|
||
| Set environment variables: | ||
|
|
||
| ``` shell | ||
| $ pwd | ||
| .../seabug | ||
| $ export CARDANO_NODE_SOCKET_PATH=$PWD/data/cardano-node/ipc/node.socket | ||
| $ mkdir -p chain-index | ||
| $ export CHAIN_INDEX_PATH=$PWD/chain-index/chain-index.sqlite | ||
| ``` | ||
|
|
||
| Fix permission problem for `node.socket` (if you receive error like: `plutus-chain-index: Network.Socket.connect: <socket: 35>: permission denied (Permission denied)`): | ||
|
|
||
| ``` shell | ||
| $ sudo chmod 0666 $CARDANO_NODE_SOCKET_PATH | ||
| ``` | ||
|
|
||
| Building and run plutus-chain-index from the source: | ||
|
|
||
| ``` | ||
| $ cd .. | ||
| $ git clone [email protected]:input-output-hk/plutus-apps.git | ||
| $ cd plutus-apps | ||
| $ nix build -f default.nix plutus-chain-index | ||
| $ result/bin/plutus-chain-index start-index --network-id 1097911063 --db-path $CHAIN_INDEX_PATH/chain-index.sqlite --socket-path $CARDANO_NODE_SOCKET_PATH | ||
| ``` | ||
|
|
||
| The index should be synced for minting. | ||
|
|
||
| #### Prepare wallet | ||
|
|
||
| ``` shell | ||
| $ cd seabug | ||
| $ nix develop | ||
| $ scripts/prepare-wallet.sh | ||
| new wallet generated: | ||
| address: addr_test1vp3tywa08qjjj7mplzmwjs9kmes0ce3ud5da3x0wppu5e9qgxqhps | ||
| PHK: 62b23baf3825297b61f8b6e940b6de60fc663c6d1bd899ee08794c94 | ||
| file: payment.addr | ||
| file: payment.vkey | ||
| file: pab/signing-keys/signing-key-62b23baf3825297b61f8b6e940b6de60fc663c6d1bd899ee08794c94.skey | ||
| ``` | ||
|
|
||
| Add some Ada to your wallet: | ||
| - by Nami wallet | ||
| - or by [Faucet](https://testnets.cardano.org/en/testnets/cardano/tools/faucet/) | ||
|
|
||
| Check the result: | ||
|
|
||
| ```shell | ||
| $ # Setup server admin token, password: seabug | ||
| $ PGPASSWORD=seabug psql -U seabug -h localhost -c "INSERT INTO admin_token(token) VALUES ('ADMIN_TOKEN')" | ||
|
|
||
| $ # Upload image | ||
| $ curl --location --request POST "locahost:8008" \ | ||
| -F "image=@./cat123.png" \ | ||
| -F "title=Cat Cat number 123" \ | ||
| -F "description=Cat eating piece of cheese" \ | ||
| -H "Authorization: ADMIN_TOKEN" | ||
|
|
||
| $ # Get IPFS CID, replace SHA_256_HASH with hash from previous response, note "ipfsHash" | ||
| $ curl --location --request GET 'localhost:8008' \ | ||
| | jq 'to_entries[] | select (.value.sha256hash=="SHA_256_HASH")' | ||
|
|
||
| $ # Convert CID, replace "IPFS_HASH" with hash from previous response, note the result | ||
| $ ipfs cid format -b=base36 IPFS_HASH | ||
|
|
||
| $ # Configure keys for BPI | ||
| $ cd plutus-use-cases/mlabs | ||
| $ cardano-cli address build \ | ||
| --payment-verification-key-file payment.vkey \ | ||
| --out-file payment.addr \ | ||
| --testnet-magic 1097911063 | ||
| $ cardano-cli address key-gen \ | ||
| --verification-key-file payment.vkey \ | ||
| --signing-key-file payment.skey | ||
| $ mkdir -p pab/signing-keys | ||
| $ cat payment.addr | ||
| $ mv payment.skey pab/signing-keys/signing-key-PKH_HERE.skey | ||
|
|
||
| $ # Start BPI, note "minting-policy", it will be used later | ||
| $ nix develop -L -c cabal run efficient-nft-pab | ||
|
|
||
| $ # In other console | ||
| $ # Mint underlying CNFTs, replace "CONVERTED_CID" with the result of `ipfs` command | ||
| $ curl --location --request POST 'localhost:3003/api/contract/activate' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --data-raw ' | ||
| { | ||
| "caID": { | ||
| "tag":"MintCnft", | ||
| "contents":[ | ||
| { | ||
| "mc'"'"'name":"Cat number 123", | ||
| "mc'"'"'description":"Cat eating piece of cheese", | ||
| "mc'"'"'image":"ipfs://CONVERTED_CID", | ||
| "mc'"'"'tokenName":"cat-123" # This should be hex encoded (without 0x) | ||
| } | ||
| ] | ||
| } | ||
| }' | ||
|
|
||
| $ # Go back to previous terminal and stop BPI | ||
| $ # Replace "CURRENCY_SYMBOL" in /efficient-nft-pab/Main.hs with currency symbol from BPI log | ||
| $ # Restart BPI, note "seabug-mint-request" | ||
| $ nix develop -L -c cabal run efficient-nft-pab | ||
|
|
||
| $ # Mint SeaBug NFT | ||
| $ curl --location --request POST 'localhost:3003/api/contract/activate' | ||
| --header 'Content-Type: application/json' \ | ||
| --data-raw 'INSERT_seabug-mint-request_HERE' | ||
|
|
||
| $ cd ../cardano-transaction-lib | ||
| $ # Replace value of "mintingPolicy1" in seabug_contracts/MintingPolicy.js with policy noted from BPI | ||
| $ cd seabug | ||
| $ cardano-cli query utxo --testnet-magic 1097911063 --address $(cat payment.addr) | ||
| TxHash TxIx Amount | ||
| -------------------------------------------------------------------------------------- | ||
| ed11c8765d764852d049cd1a2239524ade0c6057a3a51146dc8c9d7bcbe008e0 0 100000000 lovelace + TxOutDatumNone | ||
| ``` | ||
|
|
||
| #### Mint your own NFT | ||
|
|
||
| If you have an image: | ||
|
|
||
| ``` shell | ||
| $ cd seabug | ||
| $ scripts/mint-nft.sh | ||
| Arguments: <IMAGE_FILE> <TITLE> <DESCRIPTION> <TOKEN_NAME> <MINT_POLICY> [<IPFS_CID>] | ||
| <MINT_POLICY> - arbitrary string to identify mint policy | ||
| $ scripts/mint-nft.sh 'image.jpeg' 'Title' 'Description' 'Token name' 'mintPolicy' | ||
| ``` | ||
|
|
||
| The script take some time to work, especially if you haven't used efficient_nft_pab before (`cd plutus-use-cases/mlabs && nix develop -c cabal run efficient-nft-pab --disable-optimisation`). | ||
|
|
||
| If you already uploaded the image to nft.storage and have IPFC_CID (you can get it from nft.storage web interface). | ||
|
|
||
| ``` shell | ||
| $ cd seabug | ||
| $ scripts/mint-nft.sh 'image.jpeg' 'Title' 'Description' 'Token name' 'mintPolicy' k2cwueaf1ew3nr2gq2rw83y13m2f5jpg8uyymn66kr8ogeglrwcou5u8 | ||
| ``` | ||
|
|
||
| ## Components | ||
|
|
@@ -144,6 +156,10 @@ $ # Replace value of "mintingPolicy1" in seabug_contracts/MintingPolicy.js with | |
|
|
||
| Frontend for Seabug marketplace, interacts with Cardano blockchain using `cardano-transaction-lib`. | ||
|
|
||
| ### `seabug-contract` | ||
|
|
||
| NFT marketplace contracts in purescript. Onchain part was hardcoded as binary. | ||
|
|
||
| ### `ogmios-datum-cache` | ||
|
|
||
| Caches datums of NFTs that are on available marketplace. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| { pkgs, ... }: | ||
| let | ||
| nft-marketplace-server = | ||
| (pkgs.callPackage (import nft-marketplace-server/release.nix) | ||
| { }).nft-marketplace-server; | ||
| ogmios-datum-cache = (import ogmios-datum-cache/default.nix).packages.x86_64-linux.ogmios-datum-cache; | ||
| nft-marketplace-server = (import nft-marketplace-server/default.nix).packages.x86_64-linux."nft-marketplace-server:exe:nft-marketplace-server"; | ||
| ogmios-datum-cache = (import ogmios-datum-cache/default.nix).packages.x86_64-linux."ogmios-datum-cache"; | ||
| # FIXME: CTL version also pinned in seabug-contract. We need only one source of truth | ||
rynoV marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be fixed when we'll move from git submodules to flakes, then you can just follow input |
||
| cardano-transaction-lib-server = (import | ||
| cardano-transaction-lib/default.nix).packages.x86_64-linux."cardano-browser-tx-server:exe:cardano-browser-tx-server"; | ||
| cardano-transaction-lib/default.nix).packages.x86_64-linux."ctl-server:exe:ctl-server"; | ||
| in { | ||
| # NOTE: still can't remember it... | ||
| # ports = [ "host:container" ] | ||
| config.services = { | ||
|
|
||
| nft-marketplace.service = { | ||
| depends_on = { | ||
| nft-marketplace-server.condition = "service_healthy"; | ||
|
|
@@ -41,46 +41,61 @@ in { | |
| }; | ||
| useHostStore = true; | ||
| }; | ||
|
|
||
| cardano-transaction-lib-server.service = { | ||
| command = | ||
| [ "${cardano-transaction-lib-server}/bin/cardano-browser-tx-server" ]; | ||
| [ "${cardano-transaction-lib-server}/bin/ctl-server" | ||
| "--port" "8081" | ||
| "--ogmios-host" "ogmios" "--ogmios-port" "1337" | ||
| ]; | ||
| ports = [ "8081:8081" ]; | ||
| useHostStore = true; | ||
| volumes = [ | ||
| "${toString ./.}/data/cardano-node/ipc:/ipc" | ||
| ]; | ||
| restart = "always"; | ||
| }; | ||
|
|
||
| ogmios.service = { | ||
| command = [ | ||
| "--host" | ||
| "0.0.0.0" | ||
| "--node-socket" | ||
| "/ipc/node.socket" | ||
| "--node-config" | ||
| "/config/testnet-config.json" | ||
| "/config/config.json" | ||
rynoV marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ]; | ||
| depends_on = { cardano-node.condition = "service_healthy"; }; | ||
| image = "cardanosolutions/ogmios:v5.2.0-testnet"; | ||
| image = "cardanosolutions/ogmios:v5.5.1-testnet"; | ||
| ports = [ "1337:1337" ]; | ||
| volumes = [ | ||
| "${toString ./.}/data/cardano-node/ipc:/ipc" | ||
| "${toString ./.}/config:/config" | ||
| ]; | ||
| restart = "always"; | ||
| }; | ||
|
|
||
| ogmios-datum-cache.service = { | ||
| command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache" ]; | ||
| command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache" | ||
| "--db-connection" "host=postgresql-db port=5432 user=seabug dbname=seabug password=seabug" | ||
| "--server-port" "9999" | ||
| "--server-api" "usr:pwd" | ||
| "--ogmios-address" "ogmios" "--ogmios-port" "1337" | ||
| "--from-tip" "--use-latest" | ||
| "--block-filter" "{\"address\": \"addr_test1wr05mmuhd3nvyjan9u4a7c76gj756am40qg7vuz90vnkjzczfulda\"}" | ||
|
||
| ]; | ||
| depends_on = { | ||
| ogmios.condition = "service_healthy"; | ||
| postgresql-db.condition = "service_healthy"; | ||
| }; | ||
| ports = [ "9999:9999" ]; | ||
| useHostStore = true; | ||
| volumes = [ | ||
| "${toString ./.}/config/datum-cache-config.toml:/config/config.toml" | ||
| ]; | ||
| working_dir = "/config"; | ||
| restart = "always"; | ||
| }; | ||
|
|
||
| cardano-node.service = { | ||
| environment = { NETWORK = "testnet"; }; | ||
| image = "inputoutput/cardano-node:1.33.0"; | ||
| image = "inputoutput/cardano-node:1.35.2"; | ||
| volumes = [ | ||
| "${toString ./.}/data/cardano-node/ipc:/ipc" | ||
| "${toString ./.}/data/cardano-node/cardano-node-data:/data" | ||
|
|
@@ -95,7 +110,9 @@ in { | |
| start_period = "15m"; | ||
| retries = 3; | ||
| }; | ||
| restart = "always"; | ||
| }; | ||
|
|
||
| postgresql-db.service = { | ||
| command = [ "-c" "stats_temp_directory=/tmp" ]; | ||
| environment = { | ||
|
|
@@ -113,7 +130,9 @@ in { | |
| }; | ||
| volumes = | ||
| [ "${toString ./.}/data/postgres-data:/var/lib/postgresql/data" ]; | ||
| restart = "always"; | ||
| }; | ||
|
|
||
| nft-marketplace-server.service = { | ||
| image = "alpine"; | ||
| command = [ | ||
|
|
@@ -144,5 +163,6 @@ in { | |
| restart = "always"; | ||
| volumes = [ "${toString ./.}/config/tmp:/tmp" ]; | ||
| }; | ||
|
|
||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| nix develop cardano-transaction-lib/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh | ||
| nix develop seabug-contracts/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping broken process in readme can be confusing even if it's marked as broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if its the right move to drop the full minting util, I feel like probably not, but we can certainly do so from the readme, and add back later once fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new minting process partially relies on
mint-nft.shto upload an image to IPFS+our database and get its base36 CID, and some of the setup from this section of the readme is necessary for that to work. It's kind of hacky right now, but I'm not sure if it's worth trying to extract out the part ofmint-nft.shthat we need.Maybe we just remove
mint-nft.shfor now, but keeping the parts that are needed? The file is in git anywaysThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 43dad7d for what I meant. I can revert that commit if we want to keep the old version, but I feel like it'll just cause confusion