Do I need multiple smart contracts for my use case?

Sorry for the ambiguous question, I’ll try to make it as simple as possible:

Use Case: Alice wants to buy virtual item from Bob. Alice starts by having a smart contract lock her funds until Bob transfers the item. Since the virtual item is being traded on an off-chain marketplace, a third party (like a decentralized oracle network) confirms the trade and transfers the funds to Bob. If the trade doesn’t happen, Alice receives her money back and Bob might get penalized for failing to trade.

Summary

So basically like an atomic swap for off-chain marketplaces.

Question1 : Is a single contract enough to express this functionality? There’s also the option to create one smart contract PER trade, but that would increase costs a lot.

Question2 : Are there any good resources on integrating chainlink into algorand?

Welcome to Algorand!

Question 1:

This use case can be done using contract accounts (stateless smart contracts ASC1 -Algorand Developer Docs). Alice sends the funds to a new contract account with the contract being just generated from a template with the right parameters.

So one fresh contract per transaction as you mentioned. This is however very cheap on Algorand as the smart contract account costs nothing (you just need to have at least 0.1 Algo in it, but you will recover this 0.1 Algo at the end) and you only pay for transactions, that cost only 0.001 Algo.

Question 2:

Currently, there is no direct way to integrate chainlink in Algorand. What feature of Chainlink are you interested in?

Oh wow, 0.001 Algo for a transaction? That’s dope!

So, in order to verify that the transaction happened in that off-chain marketplace, I need to access a web API. To do it in a decentralized, safe way I’d need an oracle network. Cardano for example plans to work with Honeycomb API to connect high-quality APIs on-chain.

Anyways, from what I’ve read in the docs I have the ed25519verify() that allows a particular oracle to feed into my smart contract. Is that correct? I’m guessing oracles are still a work in progress?

Quick follow up question: Can you give me some hints for L2 ASC? Is there an ETA on its release or a technical breakdown? I can also open a dedicated thread instead

Layer-2 smart contracts are in the work. No public ETA yet.
Note that for what you are trying to do, most likely layer-1 is largely sufficient.

Regarding oracles, if you have somebody able to sign the value for you, it is already possible to implement oracles using ed25519verify (and other ideas). What is not yet available is a full ecosystem like Chainlink has.

Good to know, thanks!

So I’ve looked at contract accounts and they’re really practical and intuitive. I will implement an oracle-less version first and see how everything is going. This is exactly what I need.

Last question: Since calling oracles for confirmation is expensive as hell, I intend to confirm the trade of the virtual item with my OWN key. However, in order to avoid that I scam my customers I put collateral into the contract account, and in case of fraud on my side, the participants in the trade can call the oracle to confirm fraud and receive the collateral. Is there a word for this construct? I know that in ethereum, the optimistic rollup is based on the same idea. I’m looking for a keyword so I can communicate that more quickly lol