3

I am trying to buy an NFT through the Seaport contract but getting stuck on the SALT parameter.The Seaport contract specifies the following list of parameters as inputs.

struct BasicOrderParameters {
 
    address considerationToken; 
    uint256 considerationIdentifier; 
    uint256 considerationAmount; 
    address payable offerer; 
    address zone; 
    address offerToken; 
    uint256 offerIdentifier; 
    uint256 offerAmount; 
    BasicOrderType basicOrderType; 
    uint256 startTime; 
    uint256 endTime; 
    bytes32 zoneHash; 
    uint256 salt; 
    bytes32 offererConduitKey; 
    bytes32 fulfillerConduitKey; 
    uint256 totalOriginalAdditionalRecipients; 
    AdditionalRecipient[] additionalRecipients; 
    bytes signature; 
}

However, I cannot figure out what the salt parameter stands for and how to get it.

2 Answers 2

1

Based on my understanding, salt is typically used as a unique random value to help prevent replay attacks.

It's important to prevent replay attacks since in a replay attack, an attacker will capture and try to resend a valid transaction multiple times, and can lead to unintended effects such a DoS attack.

So therefore it's important to include salt in each transaction, and to verify that the value is different for each transaction.

As a result each transaction is unique and cannot be replayed by an attacker.

To get the random number, you can use an oracle like Chainlink do so. You can also generate the random number with pure solidity code if you can get a by hashing the chain content or a chain signature, but then that would comes to a risk that the 'pseudorandom number' can be controlled by the miner.

Here's a useful link that I used before that you can try to generate the random number (the Chainlink approach): https://betterprogramming.pub/how-to-generate-truly-random-numbers-in-solidity-and-blockchain-9ced6472dbdf?gi=50d99a47c9e5

I hope this helps! Let me know if you have any more questions.

EDIT : By the way if you're curious, here's how to generate the random number in pure solidity :

function generateSalt() private view returns (bytes32) {
    return keccak256(abi.encodePacked(block.number, tx.gasprice, randomNumber));
}
5
  • What is a replay attack, practically?
    – user610620
    Commented Dec 25, 2022 at 23:11
  • Thanks a lot, I will try that approach. Also, do you know how I would generate the bytes signature in Solidity ? Commented Dec 26, 2022 at 8:29
  • You are welcome! If you could mark my answer as valid so other people can find it more easily, that would be great! To generate the bytes signature in solidity, You can simple use the Keccak256 function from the bytes24 library. Please check the edit.
    – Anon.eth
    Commented Dec 26, 2022 at 14:15
  • @user610620, replay attacks are a type of cyber attack that happens when a valid data transmission is fraudulently repeated or delayed. cnbctv18.com/technology/…
    – Anon.eth
    Commented Dec 26, 2022 at 14:33
  • why can't the blockchain sort out what's valid or not
    – user610620
    Commented Dec 26, 2022 at 21:28
0

You can get all required NFT offer parameters by making a call to opensea seaport API, and filling in the query params.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.