contract-development – What Does feeReceiver in the Shiba Inu Source Code Do?

contract-deploymentcontract-developmentfeesmining

This question isn't really about Shiba Inu. More about how Ethereum works.

In the Shiba Inu source code (see here), there is an argument feeReceiver in the constructor (line 455) which then gets transferred some ether (line 464). See the relevant part of the source code below.

/**
     * @dev Constructor.
     * @param name name of the token
     * @param symbol symbol of the token, 3-4 chars is recommended
     * @param decimals number of decimal places of one token unit, 18 is widely used
     * @param totalSupply total supply of tokens in lowest units (depending on decimals)
     * @param tokenOwnerAddress address that gets 100% of token supply
     */
    constructor(string memory name, string memory symbol, uint8 decimals, uint256 totalSupply, address payable feeReceiver, address tokenOwnerAddress) public payable {
      _name = name;
      _symbol = symbol;
      _decimals = decimals;

      // set tokenOwnerAddress as owner of all tokens
      _mint(tokenOwnerAddress, totalSupply);

      // pay the service fee for contract deployment
      feeReceiver.transfer(msg.value);
    }

Why is this needed? And, when deploying your own token, how do you know which address to use as an argument? (You can see at the bottom of the source code page the address that was used in creating Shiba Inu.)

I understand that miners need to get paid, but why is there a need for both a miner and a fee receiver? And as you can see in the state changes of the transaction where the contract was actually launched (see here), the fee receiver actually got paid significantly more than the miner. Why is that?

Best Answer

This has nothing to do with how miners get paid. This happens automatically when you do a transaction (including deploying a contract), and it's the gas fee you pay, you dont specify who gets it, it's paid to the miner who included your traansaction in the block they found. Here it looks like the token has been created using an automated ERC20 token generator web page (like https://vittominacori.github.io/erc20-generator/create-token/) which takes a fee at deployment, and the fee would be taken by feeReceiver.transfer(msg.value);. This is unrelated to actually mining the transaction and is just an additionnal fee (the deployer still has to pay gas on top of that)

Related Topic