quick question anyone knows how to get the signature bytes4 (msg.sig) of a function from an external call from another contract ?
Jul 1, 2022, 8:16 PM
when i use bytes4 addEthC = msg.sig; i get the signature from the function that sets the variable, want the function of origin
Jul 1, 2022, 8:18 PM
I'm pretty sure that you're limited to what you can find here:
https://docs.soliditylang.org/en/v0.8.13/units-and-global-variables.html#block-and-transaction-properties
So you're out of luck
Jul 1, 2022, 8:47 PM
Found another solution instead of using function signature. Think it can be done with solidity inline assembly
Jul 1, 2022, 8:51 PM
What even is your goal?
Jul 1, 2022, 9:02 PM
the token I'm making right now regulates its own supply within the lp pair based on price setting from external validators, it is also also determined by buys and sells. For it to work users cant be allowed to add liquidity to that specific pair, it regulates its own liquidity, that is what i needed a solution for.
Jul 1, 2022, 9:08 PM
I don't understand it entirely. Are you trying to make a token that cannot be used in a decentralized exchange?
Jul 1, 2022, 9:17 PM
How come adding liquidity messes the price...
Jul 1, 2022, 9:19 PM
it doesn't, if more weth is added on buys, more tokens are added to lp to maintain price the validator sets, lp supply stays the same
this is an issue
Jul 1, 2022, 9:21 PM
Oh you want to maintain lp token supply a constant?
Jul 1, 2022, 9:22 PM
yes, there will only be added liquidity once
Jul 1, 2022, 9:22 PM
Thats a tough one. Btw applying limit on router level can be circumvented easily
Jul 1, 2022, 9:24 PM
yeah, limit wont do it, tried messing with function signature, no luck on that
Jul 1, 2022, 9:32 PM
unless you use a dex you build you have no way to distinguish between an add of liquidity or a sell or a withdraw of lp and a buy
btw reading through solidity's changelog just found out something cool
https://soliditytips.com/articles/concatenate-strings-solidity/
https://soliditytips.com/articles/concatenate-strings-solidity/
way more readable then the previous solution we got used to
Jul 1, 2022, 11:03 PM
it is on a dex i build, just didn't account for it when i made it
Jul 1, 2022, 11:05 PM
yeah by dex you build I meant something foe which you can adjust code to fix that, if that's already deployed and is not upgradable that won't change anything
Jul 1, 2022, 11:06 PM
absolutly
Jul 1, 2022, 11:08 PM
oh damn
thats sweet !
Jul 1, 2022, 11:10 PM
Yeah! Ahahah
Jul 1, 2022, 11:11 PM
yep yep, always read them when you see a new version
Jul 1, 2022, 11:17 PM
do we have substring (in js) equivalent in solidity?
Jul 2, 2022, 10:42 AM
Not natively, either you code it or Idk, maybe you can find a 3rd party lib that has it implemented
https://github.com/Arachnid/solidity-stringutils
Jul 2, 2022, 10:47 AM
why they should be the same?
that is a modifier
Jul 2, 2022, 11:12 AM
Yes i know ! And all modifications are made each it's call, isn't it?
Jul 2, 2022, 11:15 AM
It's using a syntax that you could've made yourself in every solidity version I'm aware of
Only natively supported in calldata
Jul 2, 2022, 7:55 PM
Mmhh no, string.concat hasn't always been around
Jul 2, 2022, 8:00 PM
Read again: you could've defined it to be exactly like that function
Jul 2, 2022, 8:00 PM
Yes, of course I could have written a function to behave in the same way
Jul 2, 2022, 8:01 PM
You could've made a contract or a library and you could've implemented a function "concat()" in it that behaves identically
Jul 2, 2022, 8:01 PM
Of course
Jul 2, 2022, 8:01 PM
Well that's not always the case. So no "of course"
For example the call data slicing was not available until recently
You couldn't have written a function that behaved identically (i.e. no gas costs)
Jul 2, 2022, 8:02 PM
Well, it's not like we didn't have a way to concat strings before that and I didn't think there was even a nees to explicit it
Jul 2, 2022, 8:02 PM
And you also couldn't have yielded that syntax
Jul 2, 2022, 8:03 PM
Mmh
Jul 2, 2022, 8:05 PM