Giter VIP home page Giter VIP logo

Comments (22)

dekz avatar dekz commented on July 19, 2024

from 0x-starter-project.

GrantGochnauer avatar GrantGochnauer commented on July 19, 2024

I get the same error on my setup too. I’m using a custom erc 721 token and haven’t quite figured out what the source of the invalid signature is yet. Is there a way to get more information on why the signature was invalid?

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

@GrantGochnauer this starter project has a example of using ERC721.

It's hard to figure out and report to a user why a signature is invalid.

Here are the 3 common scenarios currently (and we're working towards reducing these edge cases):

  • Metamask inconsistencies in their eth_sign implementation. In 0x.js there is SignerType.Metamask to help 0x.js figure out it needs to perform a work around.
  • Order hash is calculated incorrectly when order values are strings not BigNumbers, this is fixed on master soon to be published.
  • Using web3.js directly to sign (some providers spit out different formats for v,r,s values of an ec signature).

Easiest way to help us point you in the right direction:

  • Paste the signature
  • Paste the order and the order hash
  • Share how you're reading/constructing an order and ensuring the amounts (and salt and expiry time) are all BigNumbers (see here for the Order type

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

Sorry for the late response, this is my code

async function (orderType, QuoteTokenAddress, BaseTokenAddress, QuoteTokenDecimal, 
BaseTokenDecimal) {
 var makerAssetAmount
 var takerAssetAmount
 var makerAssetData
 var takerAssetData

 const web3js = window.web3
 const provider = web3js.currentProvider

 const contractWrappers = new ContractWrappers(provider, { networkId: NETWORK_CONFIGS.networkId })
 if (typeof web3js !== 'undefined') {
   const relayerApiUrl = StaticLinks.relayerApiUrl
   const httpClient = new HttpClient(relayerApiUrl)

   const web3Wrapper = new Web3Wrapper(provider)
   const addresses = await web3Wrapper.getAvailableAddressesAsync()
   const maker = addresses[0]

   const price = new BigNumber(this.price)
   const amount = new BigNumber(this.amount)

     makerAssetAmount = (Web3Wrapper.toBaseUnitAmount(price, QuoteTokenDecimal) * amount).toString()
     takerAssetAmount = (Web3Wrapper.toBaseUnitAmount(amount, BaseTokenDecimal)).toString()
     makerAssetData = assetDataUtils.encodeERC20AssetData(QuoteTokenAddress)
     takerAssetData = assetDataUtils.encodeERC20AssetData(BaseTokenAddress)
  
   // Generate and expiration time and find the exchange smart contract address
   const randomExpiration = getRandomFutureDateInSeconds()
   const exchangeAddress = contractWrappers.exchange.getContractAddress()

   // Ask the relayer about the parameters they require for the order
   const orderConfigRequest = {
     exchangeAddress,
     makerAddress: maker,
     takerAddress: NULL_ADDRESS,
     expirationTimeSeconds: randomExpiration,
     makerAssetAmount,
     takerAssetAmount,
     makerAssetData,
     takerAssetData
   }

   const orderConfig = await httpClient.getOrderConfigAsync(orderConfigRequest, {
     networkId: NETWORK_CONFIGS.networkId
   })

   // Create the order
   const order = {
     salt: generatePseudoRandomSalt(),
     ...orderConfigRequest,
     ...orderConfig
   }

   // Generate the order hash and sign it
   const orderHashHex = orderHashUtils.getOrderHashHex(order)

   const signature = await signatureUtils.ecSignOrderHashAsync(
     provider,
     orderHashHex,
     maker,
     SignerType.Default
   )

   const signedOrder = { ...order, signature }

   // Validate this order
   const sadasd = await contractWrappers.exchange.validateOrderFillableOrThrowAsync(signedOrder)
   // Submit the order to the SRA Endpoint
   const eerter = await httpClient.submitOrderAsync(signedOrder, { networkId: NETWORK_CONFIGS.networkId })
 }

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024
const web3js = window.web3
const provider = web3js.currentProvider
...
   const signature = await signatureUtils.ecSignOrderHashAsync(
     provider,
     orderHashHex,
     maker,
     SignerType.Default
   )

If window.web3 is provided by Metamask then you need to inform 0x of this (since Metamask has a non standard eth_sign implementation. We do this in the codesandbox example.

   const signature = await signatureUtils.ecSignOrderHashAsync(
     provider,
     orderHashHex,
     maker,
     SignerType.Metamask // indicate Metamask is signing this message (so it prefixes before signing)
   )

0x-starter-project uses SignerType.Default since the MnemonicSubprovider is a spec compliant implementation of eth_sign.

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

If i use providerEngine instead of window.web3 is provided by Metamask in signature does it automatically sign with metamask without notify the user as SIGN your order

const signature = await signatureUtils.ecSignOrderHashAsync(
providerEngine,
orderHashHex,
maker,
SignerType.Default // indicate Metamask is signing this message (so it prefixes before signing)
)

Getting this error
image


After using
SignerType.Metamask
its getting signed but i am getting below error
image
How to solve this problem

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

make sure all of your amounts are BigNumbers and not strings. Looks like the takerAssetAmount you are supplying is a string.

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

Ya i changed into BigNumbers after that too i am getting this error
image

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

Where is that error originating from?

Can you paste the order and signature as well

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

order
image

signature
0x1c35cf79db6768c953a10cff4d96f94eabfb76e969841a86a73185d8e3617e4ba8262828e72eebd8f31b85393cb687094f6faa63dc186b86cfd799e673a005532803

These above details are my order and signature

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

Your makerAssetAmount looks like it is still a string.

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

Is that the problem but it has to make it to string

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

https://github.com/0xProject/standard-relayer-api/blob/master/http/v2.md in this JSON all are mentioned as string only. then what problem i am facing so far

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

Ok..
When i try to connect with MAINNET it doesnt fetch the address. Here what will be the pbrolem

export const providerEngine = new Web3ProviderEngine()
providerEngine.addProvider(new RPCSubprovider('https://mainnet.infura.io/'))
providerEngine.start()

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

That provider engine config looks fine for data requests only (no accounts or signing), what do you mean by it doesn't fetch the address?

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

I meant that it is fetching the address but not my actual address which i signed currently it used to fetch some other 10 addresses.

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

That's because you haven't configured it to point to a Signer, INFURA only supports data fetching.

See the 0x Codesandbox for an example

export const providerEngine = new Web3ProviderEngine()
providerEngine.addProvider(new SignerSubprovider(web3.currentProvider)) // add a signer i.e Metamask web3
providerEngine.addProvider(new RPCSubprovider('https://mainnet.infura.io/'))
providerEngine.start()

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

If i try to connect with Ledger too will the above code work

from 0x-starter-project.

dekz avatar dekz commented on July 19, 2024

You will need to use the Ledger subprovider to connect the ledger. There is a Ledger example in our wiki.

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

ok ..
How to auto refresh if connected with metamask, metamask logged out account change and order place balance decrement

from 0x-starter-project.

narmadhasugumar avatar narmadhasugumar commented on July 19, 2024

Why i am getting error like this while placing the order in testrpc. i have 82 weth balance in am testnet
weth 3.2
zrx 9
image

from 0x-starter-project.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.