2

To send funds in a function call to another contract you can use something like this: contract X { function transfer(address dest, uint amount) public { ... } } contract Y { function take() public payable { // Reference an existing contract at an address X ref = X(addressOfX); // or if creating a new instance at a new address: X ref = new X();...


2

The ("official") Solidity compiler and associated utilities are written in C++. But Solidity is its own language with its own grammar. does that mean that smart contracts require some level of C++ programming skills to get by? No. You could write a Solidity compiler in any language you like as long as the output of compilation is valid EVM ...


1

You can use an emoji directly in a string literal in Solidity versions 0.6.12 and earlier. You cannot do so with version 0.7.0 or later. Solidity version 0.7.0 updated the parser to disallow non-printable characters in string literals. Instead, they introduced the concept of Unicode string literals, such as unicode"😃", which allows you to use ...


1

i need to make whole mapping -> uints values set to 0 If you're talking about immediately after creation, they already are. https://docs.soliditylang.org/en/v0.8.0/types.html?highlight=types#mapping-types "You can think of mappings as hash tables, which are virtually initialised such that every possible key exists and is mapped to a value whose ...


1

There's a cap to the maximum refundable gas. Only half of the total used gas can be refunded. (*) In the example at most you can refund (21000 + 5000) / 2 = 13000 gas. So it will be at 21000 + 5000 - min(13000, 15000) = 26000 - 13000 = 13000. Very close to the measured amount. (*) The exact details are in Ethereum's Yellow Paper Section 6.2 Execution.


1

The lines you showed are using the new CREATE2 opcode, instead of the regular CREATE opcode (which would be invoked by using pair = new UniswapV2Pair()). The benefit of using CREATE2 is that the contract address doesn't depend on the transaction nonce, but on other values which do not automatically change. This way the address can be predetermined. One of ...


1

__$de3f906ec3d3531c3d498f8b283d7f02e6$__ is a placeholder for library address. The deployment process of smart contracts look somewhat like this Library is compiled Library is deployed, gets an address Contract using library is compiled Contract is "linked" - all placeholders in the bytecode are replaced with the library address Contract is ...


1

Just add calldata to the parameter. So the signature should be: function performBonusCredit(string[][] calldata _toPayArgs) external payable { You can read more about these data location markers here: https://docs.soliditylang.org/en/v0.8.0/types.html#data-location


1

From the solidity compiler they are completely different functions. At runtime functions are identified by their 4 bytes selector. The function selector is calculated from the function name and the parameter types (Function Selector). If the function name remains the same but the parameters change it is very likely the selector will be different. The virtual ...


1

Just for the others who might be facing the same issue (it took me quite a while to fix it). The problem I faced was that I was calling function addLiquidityETH() without sending the ethers to Uniswap smart contract, so {value: msg.value} has to be added to the call: uniswap.addLiquidityETH{ value: msg.value }( token, amountTokenDesired, ...


1

Because currently Solidity only accepts constant state variables for Strings and value types like in the following example: pragma solidity >=0.4.0 <0.7.0; contract C { unit constant x= 32**22 - 8; string constant text = "contract"; } here is a link explaining variables, events & functions: https://www.bitdegree.org/learn/solidity-...


Only top voted, non community-wiki answers of a minimum length are eligible