Buy of ASA in exchange of Algos

Is there any usecase(using smart contract/SDK) for sample where asset can be transfered in exchange of algos(tokenization/Initial Coin Offering)?
If possible please share repo/link

1 Like

See Russ Fustino’s series:


These are just creation and transfering ASA.
I was looking more like exchange of ASA with currency in this case algos.

You are right.
Here is something more like exchange of ASA with currency:

I have tried Limit Order use case.
I get random Limit Order Address which need to be funded. Algos are transfered from this account.
I dont really understand why is this account created and not directly transfer algos from asset receiver account.
If anyone has answer please help.

See also GitHub - algorandfoundation/buildweb3: Repository for the Algorand class of the "Building with Blockchain for Web 3.0" course ( that is exactly doing what you want: selling ASA for Algos.

1 Like

Thank you, this helps a lot. step 4 is exactly what I am looking for. But doesn’t provide any SDK code or which file to run. If you can give more insight on it will be great

Hello @fabrice, on this, is there an overall solution using the DEXes on the Algorand Blockchain to do this, instead of building your own infrastructure from the ground up?

import json

from algosdk import mnemonic
from algosdk.v2client import algod, indexer
from algosdk.future import transaction
from algosdk.future.transaction import PaymentTxn, AssetTransferTxn

algod_client = algod.AlgodClient(
    # see
    headers={"User-Agent": "DoYouLoveMe?"}


passphrase_A = "six citizen candy robot jacket regular install tell end oven piece problem venture sleep arrow decorate chalk casual patient flat start upset tent abandon bounce"
private_key_A = mnemonic.to_private_key(passphrase_A)
my_address_A = mnemonic.to_public_key(passphrase_A)

passphrase_B = "strong bitter guilt theme public paper nest wild dance dry evil mixture page evidence glory lonely planet lemon trip equip shuffle fat carry about nuclear"
private_key_B = mnemonic.to_private_key(passphrase_B)
my_address_B = mnemonic.to_public_key(passphrase_B)

params = algod_client.suggested_params()

txn1 = PaymentTxn(my_address_B, params, my_address_A, int(12e6))
txn2 = AssetTransferTxn(my_address_A, params, my_address_B, 1, 14030074)

gid = transaction.calculate_group_id([txn1, txn2]) = gid = gid

stxn1 = txn1.sign(private_key_B)
stxn2 = txn2.sign(private_key_A)

signed_group = [stxn1, stxn2]

txid = algod_client.send_transactions(signed_group)
print("Send transaction with txID: {}".format(txid))

I believe soon.

1 Like

Thank you it worked for me. My next step is developing atomic transfer using smart contract. Can we do that in algorand Or is it possible only by SDK?

SDK is part of Algorand.
“Can we do that in Algorand?” – yes, you can create transactions in the command line interface or in the SDK, group them, sign them, and send the signed txns to the network.

Yes, done using SDK. Trying to do with smart contract but not sure how to write smart contract and deploy same on network. Anyone tried smart contract for atomic transfer.