LooksRare / looksrare-sdk

LooksRare TypeScript SDK
MIT License
99 stars 52 forks source link

Sign maker order #39

Open Sam53534512 opened 2 years ago

Sam53534512 commented 2 years ago

Rinkeby Test Environment:

         const signer = new ethers.Wallet(“prvatekey”);
         const signerAddress = await signer.getAddress();
         let nonce = await web3.eth.getTransactionCount(signerAddress);

       const makerOrder: MakerOrder = {
            isOrderAsk: true,
            signer: signerAddress,
            collection: "0xfE484120024431AFcbEadF09DcdCBe9f7e63671F",
            price: "10000000000000000000", // :warning: PRICE IS ALWAYS IN WEI :warning:
            tokenId: "10001", // Token id is 0 if you use the STRATEGY_COLLECTION_SALE strategy
            amount: "1",
            strategy: addresses.STRATEGY_STANDARD_SALE,
            currency: 'ETH',
            nonce: nonce,
            startTime:now,
            endTime: now + 86400, // 1 day validity
            minPercentageToAsk: Math.min(8500, 8500),
            params: paramsValue,
        };
        const { domain, type } = getMakerOrderTypedData(chainId, addresses.EXCHANGE);

        const signature = await signer._signTypedData(domain, type, makerOrder);

error:cannot resolve ENS names without a provider (operation="resolveName", value="ETH", code=UNSUPPORTED_OPERATION, version=wallet/5.6.1) someone can help me?

0xShisui commented 2 years ago

const signer = new ethers.Wallet(“prvatekey”);, you forgot the pk

Sam53534512 commented 2 years ago

forgot

yes i forgot,thanks now I'm testing rinkeby,

const chainId = SupportedChainId.RINKEBY;

let ethersProvider = ethers.getDefaultProvider('rinkeby',{ etherscan: 'key', });

const signer = new ethers.Wallet('privatekey',ethersProvider); const signerAddress = await signer.getAddress(); let nonce = await web3.eth.getTransactionCount(signerAddress);

        const makerOrder: MakerOrder = {
            isOrderAsk: true,
            signer: signerAddress,
            collection: "0xfE484120024431AFcbEadF09DcdCBe9f7e63671F",
            price: "100000000000000000", // :warning: PRICE IS ALWAYS IN WEI :warning:
            tokenId: "10001", // Token id is 0 if you use the STRATEGY_COLLECTION_SALE strategy
            amount: "1",
            strategy: addresses.STRATEGY_STANDARD_SALE,
            currency: 'ETH',
            nonce: nonce,
            startTime:now,
            endTime: now + 86400, // 1 day validity
            minPercentageToAsk: Math.min(8500, 8500),
            params: paramsValue,
        };

       const { domain, type } = getMakerOrderTypedData(chainId, addresses.EXCHANGE);
      const signature = await signer._signTypedData(domain, type, makerOrder);

Return results :signature="0xfe7c74b141e3a1d84ea4b3a460c675b24c72e376c4c1ba0dd544641676720fbd70c327758704fd1ca5f2cd03d0e038ddad23dab92c4f1faa48d2d35392f510b41b" but,It didn't succeed in listing,can you help me?

0xShisui commented 2 years ago

I think you misunderstood something. let nonce = await web3.eth.getTransactionCount(signerAddress);, the order nonce has nothing to do with the account nonce. It's an internal value managed by the LR system. Refer to https://github.com/LooksRare/looksrare-sdk/blob/master/doc/guide.md#how-to-retrieve-the-user-nonce

Sam53534512 commented 2 years ago

I think you misunderstood something. let nonce = await web3.eth.getTransactionCount(signerAddress);, the order nonce has nothing to do with the account nonce. It's an internal value managed by the LR system. Refer to https://github.com/LooksRare/looksrare-sdk/blob/master/doc/guide.md#how-to-retrieve-the-user-nonce

thanks,

i get nonce from https://api.looksrare.org/api/v1/orders/nonce, api is Right?

I replaced the original nonce with API and still couldn't create the order,NFT has no state change