hyperledger-solang / solang

Solidity Compiler for Solana and Polkadot
https://solang.readthedocs.io/
Apache License 2.0
1.26k stars 213 forks source link

ERC20 is not available on solana #1174

Open vinodsharmak opened 1 year ago

vinodsharmak commented 1 year ago

I am trying to compile my contract but getting

error: 'msg.sender' is not available on Solana. See https://solang.readthedocs.io/en/latest/targets/solana.html#msg-sender-solana ┌─ D:\Github\solana-solidity\ERC20.sol:380:16 │ 380 │ return msg.sender;

Please let me know how I can fix this ? or is there any alternative for "msg.Sender"

xermicus commented 1 year ago

Hi @vinodsharmak

The documentation you linked literally answers your question:

The way to implement this on Solana is to have an authority account for the contract that must be a signer for the transaction (note that on Solana there can be many signers too). This is a common construct on Solana contracts.
seanyoung commented 1 year ago

@vinodsharmak can you show us the solidity you are trying to compile, so we can help you re-write it without msg.sender?

vinodsharmak commented 1 year ago

Hi @seanyoung Here is the sol ERC20.txt

seanyoung commented 1 year ago

@vinodsharmak you are right, we need an ERC20 example that works on Solana. We should add this to our to do list.