#Require payment for invocation

1 messages · Page 1 of 1 (latest)

tawny plaza
#

What would be the best way to require a payment from the invoker of a contract?
Allowances would require to be set up upfront and then the contract could pay itself from the allowance.
Is there a more direct way to achieve that?

Let's say I want to issue an asset that acts as a ticket to the contract (e.g. a lottery) and invoking the contract's generate/mint fn requires payment with that ticket-asset.

edgy bridge
# tawny plaza What would be the best way to require a payment from the invoker of a contract? ...

If I understand your question correctly, what you're looking for is the advanced auth. You can build a signature for the user to pay the contract and use the signature in the contract xfer(&signature, ...). I created a tutorial to build and use signatures a while back (https://github.com/xycloo/soroban-cli-futurenet-advanced-auth), it hasn't been updated to the latest sdk yet but should give you all the info you need to do build and use a signature.

tawny plaza
#

thx. i am going to check it out

tawny plaza
#

that looks great. thank you.
if i understood correctly the UI can make the user pre-sign a sub-contract call (which may be a token xfer in my case or anything else from a technical perspective).
in your tutorial everything was done in rust. but most probably building the signature would happen in typescript or whatever is used to build the client, right?
this also implies a user already has either a soroban token or a wrapped classic asset they can pay with.

under the assumption the contract in question is the user's first touchpoint with soroban (it's already deployed they only want to invoke it), the user would need to import some classic XLM or ticket asset, invoke the contract with a signature that allows transferring the ticket token into the contract and receive the output of the contract

fallow quiver
#

we hope to make this as simple as just calling token.xfer/approve in your contract - see the 'Auth Next' proposal: