4

In plutus playground, there is an example called “Vesting”. In the simulation, users can interact with this smart contract by click on “vest fund” or “retrieve funds”.

Now suppose that we compile this into a plutus script (Vesting.plutus) and then use cardano-cli (or other tools) to actually deploy this smart contract to the real blockchain.

How would users interact with this real-world smart contract?

To be more specific, here is the hypothetical steps:

  1. User A send a transaction to vest funds to the contract.
  2. User B send another transaction to retrieve funds from the contract.

The two transactions must be different. There must be some kind of parameters to indicate that the transaction is about to vest or retrieve the fund, activating different endpoint specified in the contract.

What is the different between the build of the transaction in step 1 and 2?

3 Answers 3

2

How would users interact with this real-world smart contract?

Actually what users interact with is the address of the smart contract, the plutus code (the code that produce the hash/address of the contract) must be attached to the transaction everytime it's used as validator of the given transaction (unless CIP-33 is being used).

Everytime an user needs to interact with the smart contract, they do it using the "address" of the contract, which is the "hash" of the contract code.

There are many libraries and tools that can be used to build transactions, PlutusTx (which Playground uses) is one of them.

What is the different between the build of the transaction in step 1 and 2?

The difference is in the constraints being used, in the step 1 the contract wallet is locking the value in the contract through mustPayToTheScript, in the step 2 the contract wallet is redeeming with collectFromScript.

4

You can use cardano serialization lib to write a webapp using react and CSL to build transactions for your vesting contract, like those actions for vesting funds or retrieving funds. These transaction can then be sent to blockfrost and get submitted to a cardano node. That's how many dApps work. You can also construct the transactions on the server side, send them back to the client to be signed by the user's light wallet and then submit them to your own node. (the architecture is pretty much up to you)

0
1

As @walker-leite pointed out, you interact with the address of the validator (smart contract).

When user A send a transaction to vest funds to the contract, he actually sends the amount to the address. This is just good old sending some Ada to an address. There is no validator (smart contract) involved here.

The validator is run when the user B wants to retrieve the funds that A sent to the address. This validator code determines if user B can retrieve the funds or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.