Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 10 2017 22:42
    @jpitts banned @etherchamp1_twitter
  • Jun 05 2016 10:33
    @chriseth banned @adamskee
me.xandr
@me.xandr:matrix.org
[m]
Hi! I need help with withdrawing liquidity from PancakeSwap. There is a token - 0x1771ad5b28549467ad5fe68e9f271667a5930a2e, liquidity was created on PancakeSwap v1 paired with BUSD, then it was withdrawn for migration to v2, liquidity was created on v2 and now it is impossible to transfer the token and, accordingly, withdraw liquidity. The token has the function of 10% commission for the transfer: 5% to all holders, 5% to liquidity - most likely this is the problem. LP token on v2 PancakeSwap (Discontinued) - 0x6d4D749C8763bcf4690A10F5E0297194059BB98A.
I will pay you 750$ if we successfully withdraw funds. DM for more info on telegram @antonlss
r3alz
@r3alz

Hi, I'm looking at the guttercats smart contract. What exactly could go wrong with this function?

function adopt() private { //you would be pretty unlucky to pay the miners alot of gas for (uint256 i = 0; i < 9999; i++) { uint256 randID = random(1, 3000, uint256(uint160(address(msg.sender))) + i); if (_totalSupply[randID] == 0) { _totalSupply[randID] = 1; _mint(msg.sender, randID, 1, "0x0000"); adoptedCats = adoptedCats + 1; return; } } revert("you're very unlucky"); }

So I see that it will be a lot of gas because of the loop. Also, instead of the random() function they used they should have used chainlink oracle, right?
Also, with this function is it possible for someone to mint the same token? or does the if() statement checking for _totalSupply[randID]==0 prevent that?

3 replies
fomobot
@fomobot
What is it called when you store multiple values from multiple variables into a single uint or bytes variable using assembly or bit wise shifts , and/or how can I learn to use it properly?
Example:
    function parseMessage(bytes message)
        internal
        pure
        returns (address recipient, uint256 amount, bytes32 txHash, address contractAddress)
    {
        require(isMessageValid(message));
        assembly {
            recipient := mload(add(message, 20))
            amount := mload(add(message, 52))
            txHash := mload(add(message, 84))
            contractAddress := mload(add(message, 104))
        }
    }
I don't feel like guessing how it works via trial and error.
surk82
@surk82
can someone send some test kovan eth pls
0x259d4901D48E3818B35b74f3405B7339167Ae3F6
DingTian
@ReactTop
@fomobot
please try to read this
GuruJustin
@gurujustin:matrix.org
[m]
hi
Going to get the current prices of assets (two tokens, ex: USDT-WETH) in UniswapV3pool with web3
How should I do that?
hrkrshnn
@hrkrshnn:matrix.org
[m]
Morteza3123
@Morteza3123
Hi
Does anyone know what function we should use to automatically transfer ERC20 tokens from one wallet to another wallet?
1 reply
Lukas Hönig
@lhoenig_gitlab

Hi, whereas with 0.8.4 I receive no warnings at all, with 0.8.5 I received lots of warnings of the following form:

Warning: Unreachable code.
   --> contracts/provableAPI.sol:654:9:
    |
654 |         return provable.queryN{value: price}(0, _datasource, args);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The function it's referring to is the following:

function provable_query(
        uint256 _timestamp,
        string memory _datasource,
        string[] memory _argN
    ) internal provableAPI returns (bytes32 _id) {
        uint256 price = provable.getPrice(_datasource);
        if (price > 1 ether + tx.gasprice * 200000) {
            return 0; // Unexpectedly high price
        }
        bytes memory args = stra2cbor(_argN);
        return provable.queryN{value: price}(_timestamp, _datasource, args);
    }

I think it must be because of the stra2cbor call:

function stra2cbor(string[] memory _arr)
    internal
    pure
    returns (bytes memory _cborEncoding)
{
    safeMemoryCleaner();
    Buffer.buffer memory buf;
    Buffer.init(buf, 1024);
    buf.startArray();
    for (uint256 i = 0; i < _arr.length; i++) {
        buf.encodeString(_arr[i]);
    }
    buf.endSequence();
    return buf.buf;
}

and

function safeMemoryCleaner() internal pure {
        assembly {
            let fmem := mload(0x40)
            codecopy(fmem, codesize(), sub(msize(), fmem))
        }
    }

I suspect it's about this assembly here, but why would 0.8.5 mark it as unreachable and 0.8.4 not?

chriseth
@chriseth:matrix.org
[m]
We fixed some issues with the reachability analysis in 0.8.5 - maybe we got something wrong.
do you use inheritance? the new code considers all functions relative to all contracts, so maybe marking unused contracts as abstract could help
can you create an issue on the solidity repo together with example code?
Lukas Hönig
@lhoenig_gitlab
@chriseth:matrix.org will create an issue!
chriseth
@chriseth:matrix.org
[m]
I don't think it's an issue with the assembly. do you have functions that always revert?
Lukas Hönig
@lhoenig_gitlab

Not that I'm aware of.. we are using a pretty standard contract with this signature:

contract Wayback is usingProvable {

the other file is this one https://github.com/provable-things/ethereum-api/blob/master/provableAPI_0.6.sol with some minor patches for 0.8.x compatibility..

Lukas Hönig
@lhoenig_gitlab
I'll try to come up with a minimal example that triggers the warnings.
Lukas Hönig
@lhoenig_gitlab
@chriseth:matrix.org You're right, it doesn't have to do with the assembly. I was able to isolate the issue to the usage of library Buffer in the above mentioned file. Any function that uses Buffer AND calls any function on it is understood by solc to never return. Further than that, I'm not sure what in Buffer is causing this.
B.M
@bigman1208000
@Morteza3123
transfer() does that, but it could require a series of prerequisites depending on the context. like approve(), or even allow someone else (like an exchange) to swap on the individuals behalf with transferfrom()
ExeciN
@ExeciN:matrix.org
[m]
I'm trying to wrap my head around 2 dimensional arrays but the syntax gets in the way. Will (arr[i])[j] work? will it be different than arr[i][j]?
ExeciN
@ExeciN:matrix.org
[m]
I declared my array like this someStruct[][256] public arr; so when I do arr[i].push(x) I don't know if i refers to the static or to the dynamic part
I guess I could try something like arr[300].push(x) and see if I'm out of bounds
chriseth
@chriseth:matrix.org
[m]
just think of it as an array of arrays
when you access an element you can use parentheses
you can even assing "one dimension" to a local variable
when you declare the type then you cannot use parentheses (I think)
Lukas Hönig
@lhoenig_gitlab
@chriseth:matrix.org ethereum/solidity#11522
chriseth
@chriseth:matrix.org
[m]
thanks for reducing the example!
Lukas Hönig
@lhoenig_gitlab
No problem! :)
B.M
@bigman1208000
hello, guys sorry for interrupting but I need your help.
I'm trying to test my example Solidity contract using hardhat and I'm getting the following error:
TypeError: Cannot read property 'param' of undefined
Lukas Hönig
@lhoenig_gitlab
@bigman1208000 That looks more like a JS error than something with Solidity..
B.M
@bigman1208000
@lhoenig_gitlab Thanks for your support
Pi
@p-i-
Can anyone point me towards a good resource for learning Solidity?
DingTian
@ReactTop

contract SendEther {
function sendViaTransfer(address payable _to) public payable {
// This function is no longer recommended for sending Ether.
_to.transfer(1 ether);
}

function sendViaSend(address payable _to) public payable {
    // Send returns a boolean value indicating success or failure.
    // This function is not recommended for sending Ether.
    bool sent = _to.send(msg.value);
    require(sent, "Failed to send Ether");
}

function sendViaCall(address payable _to) public payable {
    // Call returns a boolean value indicating success or failure.
    // This is the current recommended method to use.
    (bool sent, bytes memory data) = _to.call{value: 1 ether}("");
    data = "hello";
    require(sent, "Failed to send Ether");

}

}

Hi everyone. functionalities of contract is not working to send ether now .

transact to SendEther.sendViaCall errored: VM error: revert.

revert
The transaction has been reverted to the initial state.

This is issue.
Anyone has idea ?
melbourne2991
@melbourne2991
Does anyone here have any experience deploying ERC1155 Factory contracts to opensea?
mongolsteppe
@mongolsteppe
Hi, I am writing some tests for my contract and one of its functions has a require such as this:
require(amount > 0, "Your current balance is 0");
Is there any way to verify with a test function that I'm getting the 'Your current balance is 0' exception? My intention is to have a test that passes if the wrong address calls the function and that require fails. Thanks!
Lukas Hönig
@lhoenig
@mongolsteppe try Hardhat in combination with waffle and ethers.io for testing. It‘s amazing. We do unit as well as integration tests with no problems.
mongolsteppe
@mongolsteppe
@lhoenig Will do, thanks!
phalexo
@phalexo
Hi, I am writing some tests for my contract and one of its functions has a require such as this:
require(amount > 0, "Your current balance is 0");
Is there any way to verify with a test function that I'm getting the 'Your current balance is 0' exception? My intention is to have a test that passes if the wrong address calls the function and that require fails. Thanks!
try {
// your code
assert.fail("Your current balance is 0");
}
catch error {
// code to handle error
}
//Something like this in Truffle