1

I am totally new to this and I am trying to learn more about smart contracts and token creation. I started by copying a smart contract from Github and essentially I have pasted it into Remix

This is the one I picked:

https://github.com/safemoonprotocol/Safemoon.sol/blob/main/Safemoon.sol

I have seen a few of these contracts and they are all the same.

I successfully deployed this contract to the Binance TestNet using the Meta Mask integration - but there are no callable functions to use in Remix. The only option is the low level interaction "call data".

My question is:

  • how are the folks using these contracts to create an initial supply of tokens? Do they call a function of some sorts?
  • how can you call the functions in the contract for testing purposes?
  • is there something different about this type of sol file which I need to be aware of compared to other examples I have seen?

Thanks for helping someone new out.

1

Inside the single file you pointed to are several contracts and libraries. You may have previously seen .sol files that contain only one contract or library.

When you compile the file as a whole in Remix, the resultant compiled contracts/libraries are then listed in alphabetical order in a drop-down menu on the left. Remix "selects" the first contract in the list, so that any user actions - such as inspecting the compilation details, or deploying the code - apply to that contract. Alphabetically the first contract is Address.sol, a library that contains a series of internal functions.

Because the functions are all internal, they can't be called from a public interface - they can only be used by a contract that includes the library programmatically.

What you will need to do is select the contract you want to call in the list, at which point you should see the functions you want to call.

5
  • Thanks - that seems to be it, very well explained. I selected the correct contract that I want to deploy and it takes 3 parameters: string memory name, string memory symbol, address routerAddress. <--- any ideas what this needs to be? Apr 21 at 15:53
  • That's going to be the name of the token, the symbol of the token, and the address of the deployed Uniswap router. If you're deploying your own router, then you'll need to do that first, save the address where it was deployed to, and then pass it to the other contract. If you're using an existing router you'll need to know the address. (As the other answerer mentioned, this is quite a complex chain of interactions to be dealing with!) Apr 21 at 15:59
  • Can this be deployed to the Binance smart chain (test net) with a uniswap router address? I tried with this address 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D and got an error: Internal JSON-RPC error. { "code": -32000, "message": "gas required exceeds allowance (30000000) or always failing transaction" } Apr 21 at 16:13
  • You can't use Ethereum addresses on the Binance chain - they are two separate, non-connected chains. The Binance equivalent is PancakeSwap. I think it's a straight copy of Uniswap, so will have the same router setup. The contracts are here -> bscscan.com/token/0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82 Apr 22 at 8:29
0

I would suggest you start off with something simple try creating an erc20 token on a testnet refer this https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol the low level interaction function is the fallback i.e if a method does not exist in the contract then the fallback is called but as I said start off with a simple erc20 contract.

2
  • Thanks I will take a look at that, since I copied the contract as is - any ideas why the functions do not appear in remix? Apr 21 at 15:23
  • the contract you compiled and deployed did not have any functions that's why it seems like try the erc20 one in remix there is a dropdown and you need select the right contract you want to deploy
    – viraj
    Apr 21 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.