Create a systemctl process - Cardano NFT Auto-Mint System

Hi,

I am following the steps given in https://github.com/ejane24/Cardano-NFT-Auto-Mint .

I am facing problem in step 5 - Create a systemctl process

I am not able to create/update auto-mint.service file.

I think there can be any permission issue.
Please suggest any solution or any alternative to this script will also work.

Thanks & Regards,
Ishan

That might be. A normal user is not allowed to write in /etc or /usr and cannot do systemctl enable and systemctl start. Just prefix the commands in that step with sudo.

1 Like

Thank you @HeptaSean ,

image

Can you help me this error.

Did you copy the file verbatim from https://github.com/ejane24/Cardano-NFT-Auto-Mint#step-5—create-a-systemctl-process?

The Description=… at the end of the first line is definitely wrong and could lead to such an error.

1 Like

So what should we replace that Description with ?

Just without the additional description in the first line should work:

[Unit]
Description=Auto Minting Service

[Service]
Environment="CARDANO_NODE_SOCKET_PATH=/root/cardano-my-node/db/socket"
ExecStart=/usr/bin/mint.sh
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
1 Like

Thank you @HeptaSean .

image
Can you help me with this error.

It cannot find cardano-cli.

Where is it installed?

Since mint.sh is run from a systemd service, it is run as root and cannot be found if it is only available in a path added to your user’s .bashrc.

Easiest way is to copy it to /usr/local/bin, where it is also found for the root user. But then, you have to remember to do that copy after every update.

Less hacky would be to add the location of cardano-cli to the $PATH for this systemd unit: https://askubuntu.com/a/1014553

1 Like

I copied the file to /usr/local/bin . But still same error

image

Oh, no, I meant that you copy cardano-cli to /usr/local/bin, so that mint.sh can find it. Sorry.

1 Like

Note you do not actually need to create a systemd unit file nor a background daemon to achieve “auto-minting” at all. That said you can learn more about unit file definitions, including additional options you may want to set, in the man page or the online docs: systemd.unit

Overall this system is much more useful for “system services” that should always be on like your network. Run systemctl or systemctl status to get an idea of the kinds of things that belong here. Alternatively, a simple crontab would suffice, a timeout and/or recursion in the mint script itself, or various other “keep doing this” methods …

Hi @HeptaSean

image

I am still getting this error. Please help.

Sorry for the late answer!

If you really only did sudo cp -r /home/ubuntu/cardano-src /usr/local/bin, then that won’t help anything. It copies the whole folder into /usr/local/bin, so that you should now have /usr/local/bin/cardano-src, but only the binaries directly in /usr/local/bin are found, not all binaries in subfolders. Also copying the whole source folder there is a bit much.

You can check, where cardano-cli is by which cardano-cli or command -v cardano-cli. If you followed https://developers.cardano.org/docs/get-started/installing-cardano-node/#building-and-installing-the-node, it should be /home/<your user>/.local/bin/cardano-cli. Then copy that binary and only that binary to /usr/local/bin (because a systemd service cannot find it if it is only installed locally for one user): sudo cp /home/<your user>/.local/bin/cardano-cli /usr/local/bin/

(To undo the non-working stuff and leave less clutter behind, you might want to do: sudo rm /usr/local/bin/mint.sh and sudo rm -r /usr/local/bin/cardano-src.)

1 Like

Do you mean that the minting could be initiated by the web server (or whatever results in the preconditions of a new mint)? Yes, I would maybe build it that way, also, but I fear a lot of users need a detailed how-to.

The script https://github.com/ejane24/Cardano-NFT-Auto-Mint/blob/main/process.sh used here already has “keep doing this” in it. The systemd unit just ensures that it is started on boot and kept running.

Would I write it differently? Yes. (Waiting 5 seconds between UTxOs already grabbed seems odd, not waiting between the queries also.)

Do I have written a better alternative that I can give to users? Unfortunately No.

No worries, it just seemed liked they were having trouble configuring and installing the service so I was thinking a crontab for the script or just running loop with a timeout might be simpler for the OP.

Not sure what the end goal is but long-term I would vouch for a web server or something with a load balancer that was event driven but that is WAY outside the scope here.

1 Like

Hey @HeptaSean & @DinoDude ,

My end goal is to do an ICO on Cardano chain. Do you believe this script can help us achive it or there are any other better alternatives ?

Depends. This script is obviously for distributing NFTs and not for distributing coins/fungible tokens.

If that is what you want to do – an NFT project, not an ICO – maybe the service linked at the top of that github repo or any other third-party NFT minting service would suit you better.

If the value proposition of your coins is some technology built on Cardano, then you should really have someone on your team who can build a better coin distribution system more tightly integrated with your solution.

If the value proposition of your coins is something else that does not need technological expertise on Cardano, then my skepticism is triggered a bit. With some specification of what exactly it is that you want to do, this script could be modified or a new one written that does an ICO.

2 Likes

Hi @HeptaSean ,

Can you provide some resources for writing an ICO script .

That is a very general question.

Do you know any programming language in which you want to do it?

Just as a shell script like the one we were starting with, here?

Minting (and sending) native tokens in general is described here:
https://developers.cardano.org/docs/native-tokens/

If you want to do it with Javascript and submit transactions via Blockfrost or Koios, starting point could be:
https://github.com/Emurgo/cardano-serialization-lib/tree/master/doc/getting-started

You would have to do a few design decisions:

  • Do you want to have a fixed amount of your tokens and your ICO closes when they are all distributed?
  • Or should an arbitrary number of tokens be minted on demand, when people pay to your ICO system?
  • Do you want to do dedicated receive addresses for each customer, perhaps with progress tracking on website (would need a bit of web development), or one address for all without feedback?
  • Tokens shall be sent back to the address sending the ADA?
  • How many tokens per ADA sent?
  • What do you want to do with incoming transactions that have wrong amounts of ADA? Or if you have limited amount of tokens if they are empty?
1 Like

I know solidity. I have knowledge on ICO for ethereum.

I have minted and burned tokens using cardano-cli and policy bounded script.

How to define max token amount?

I want something like I can stop minting after ICO but burning should be forever open, as I’ve created timebound policy token, I’m not able to achieve this.

Whichever works best, i won’t have problem with web development

Yes

As now we can take as 1 ADA= 10 NativeToken

Will not send anything to that as we have minimum investment amount . If there is anything we can put condition to stop this kind tx as we have in ETH SC