2

I'm thinking about making a parameterised contract between two users. User A can be anyone i.e. any customer, But User B should always be the company. I want to make it so that the validator only validates if the Company signs the contract. How do I do this?

Also, How would both signatures be sent to the contract, without making it easy for somebody to fake the signature of the company?

1 Answer 1

2

So, at a high level, you can't make any restrictions on who can create a script, or submit datums to a script address. You can only put restrictions on who can "spend" datum utxos at the script address.

So, one solution is you specify a token that needs to be attached to the datum for it to be spent. That token's minting policy requires the minter to be User B.

User B can create an active instance of the script by submitting a datum attached to the token only she can create. This would essentially be the same as signing the contract, as User B would need to sign the tx that created that token.

The script will only allow User A and User B to spend that datum and make state changes if the "signing" token exists on the UTxO.

8
  • 2
    Note: You'd probably want to take care that the "signing" token can never be sent to a wallet, only to the script address. Otherwise it's essentially a blank check. Jun 7 at 17:47
  • 1
    I don't think there is one correct answer. But you can't modify scripts ever. Script addresses are the hash of the code the validates it. So, if you modify the script, it will change the address. That doesn't mean you can't make your SC upgradable. The upgrades will just cause it to use new scripts. Well designed SCs could be backwards compatible if participants want to interact with old scripts. A script isn't the same thing as a SC. Multiple SCs can use the same script, and SCs can use many scripts and minting policies. Jun 8 at 22:32
  • 1
    All datums are attached to a UTxO. And UTxOs have a Value field that can include multiple native tokens. Jun 10 at 16:39
  • 1
    Haha. Thanks. Don't worry about it. I can't tell you how to build your app, but here's an example of off-chain code combining multiple tokens into a single value: github.com/input-output-hk/plutus-apps/blob/… Jun 12 at 3:31
  • 1
    Thanks man that's perfect.
    – KryptoKing
    Jun 12 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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