Help (example code) for sending EUROe from concordium smart contract

Hi,

Need help. I’m working on a concordium smart contract that will send EUROe to an account. Do you have an example code (within a receive function of a concordium contract) to share that sends EUROe to a different account? I know I can already have EUROe in my concordium wallet account (sender in my contract). I can get it via EUROe faucet for testing. So how do I send some EUROe to another account? Do I need to call the EUROe contract (in another thread) to transfer and how can I do this in code? How can I tell my contract to invoke and transfer EUROe instead of CCDs? Can someone please give an example code? How can I check the balance before sending anything?

Thanks.

Hi there.

I am not entirely sure what you want to do, but we have a number of examples here.
You might already know this, but EUROe implements both CIS-2 and CIS-3, so you might want to take a look at examples related to these standards.

I have tried to answer your questions, but knowing more of your project would probably allow me to better point you in the right direction.

Do you have an example code (within a receive function of a concordium contract) to share that sends EUROe to a different account?

We have an auction contract example, which does a CIS-2 transfer here, this example supports any CIS-2 token so also EUROe.
See the Cis2Client::transfer for more documentation.

So how do I send some EUROe to another account?

You can manually transfer from any of the wallets which support CIS-2 transfers.
At the time of writing, this might only be the web-wallet (chrome extension), but I’ll need to check up on this.

Do I need to call the EUROe contract (in another thread) to transfer and how can I do this in code?

If you mean from within a smart contract then see the answer above. If you want to do a EUROe transfer from a dApp off-chain, then it probably involves one of the SDKs and some of the SDKs will have examples of this. In any case, you need to interact with the EUROe smart contract since a token contract is essentially just ‘a registry of who owns how much’.

Related to whether to use threads, this only makes sense off-chain, since there cannot be threads in a smart contract and it will depend on you setup.

How can I tell my contract to invoke and transfer EUROe instead of CCDs? Can someone please give an example code?

So one thing that is important to understand, is that CCDs are native to smart contracts, so there is a transfer specifically for this. EUROe is a CIS-2 token meaning transfers are done by interacting with the EUROe contract. Se my answer for the first question for an example.

How can I check the balance before sending anything?

Any CIS-2 token (including EUROe) provides a function for querying a balance of any address called balanceOf, so if you mean from within a smart contract, then you can query your own contract address using Cis2Client::balance_of.

1 Like