Quick question:
I have an object O that is represented as a mapping ------ id => struct_of_9_fields.
What is the best way to check something that at least 1 of the corresponding fields in 2 given ids are different?
I.e. (field1(id1) != field1(id2)) || (field2(id1) != field2(id2)) || ...

In other languages it is possible to compare lists or tuples so if i have [1, 2, 3] == [1,2,4] i get false.
Is it possible to do in solidity using tuples?
Bare in mind that different fields are of different types - uint256, address, bytes32, uint8, ERC20, etc...

Dec 20, 2021, 11:09 AM
@jampik Did You write the smart contract?
Dec 20, 2021, 11:22 AM
I don't think tuple comparison is possible, even for same type
Dec 20, 2021, 11:26 AM
Is there a way to compare a list of values with respect to position?
Dec 20, 2021, 11:27 AM
Struct1 memory foo;
Struct2 memory bar;
while(i < structLength){
foo[i] == bar[i];
}
There would be a better way though
Actually, no need to iterate, direct foo == bar works
Dec 20, 2021, 11:37 AM
I already thought about this one and the if || case.
Oh really? So i can equate values of structs directly?
Dec 20, 2021, 11:38 AM
It compares one struct entry with the other, yeah
No wait, I was wrong
You need to take hash
https://ethereum.stackexchange.com/questions/49951/compare-structs-and-arrays-with-keccak256-in-order-to-save-gas
https://github.com/ethereum/solidity/issues/9598
Still an open issue in solidity git :(
Dec 20, 2021, 11:46 AM
Yes
Dec 20, 2021, 2:30 PM
A disclaimer first - im not a developer and have never wrote an ERC721 or anything like that, but after taking a look at OZ ERC721 implementation it seems (and make sense to me) that in order to have royalties set you need to have access to the full transaction, i.e. it is not enough to know the cain of owners of a specific token, you also need to know the value at which it was bought.

Think about it this way - you can set a creator constart var for your token ID and a royalties amount const/%.
Whenever you make a transfer of a specific token you can actually make sure that a safeTransfer of another ERC20/721 will be made by having in the ERC721 Transfer code block, however you can only make ask for a const fee, not a percentage because the entire deal - NFT for ETH for example - is being executed by the exchange
I believe what services like rarible are doing is having a collaboration with some of the big exchanges to (i.e. all use their exchange protocol or are able to integrate to it). If you were to open an exchange with your ERC721 the rarity royalties percentage would've probably not work. same goes for free trade between 2 individuals.

Everything i say is just a hunch. If I were you i would've check it. go to rarible and read the FAQ or whatever, see if on what exchanges you can use their features
Dec 20, 2021, 2:59 PM
What rarible and opensea do is basically run the biddings / sales on their servers and take a fee for a successful purchase (off chain)
if you want to implement royalties within the NFT contract then you'd have to set the rules for multistage 100% on chain sales/auctions
Dec 20, 2021, 4:18 PM
Interesting. I never used it i admit. I expected it to still be on chain
Dec 20, 2021, 5:04 PM

© 2024 Draquery.com All rights reserved.