Comments (22)
from 0x-starter-project.
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.
@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 isSignerType.Metamask
to help 0x.js figure out it needs to perform a work around. - Order hash is calculated incorrectly when order values are
strings
notBigNumbers
, 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.
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.
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.
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)
)
After using
SignerType.Metamask
its getting signed but i am getting below error
How to solve this problem
from 0x-starter-project.
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.
Ya i changed into BigNumbers after that too i am getting this error
from 0x-starter-project.
Where is that error originating from?
Can you paste the order and signature as well
from 0x-starter-project.
signature
0x1c35cf79db6768c953a10cff4d96f94eabfb76e969841a86a73185d8e3617e4ba8262828e72eebd8f31b85393cb687094f6faa63dc186b86cfd799e673a005532803
These above details are my order and signature
from 0x-starter-project.
Your makerAssetAmount
looks like it is still a string.
from 0x-starter-project.
Is that the problem but it has to make it to string
from 0x-starter-project.
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.
from 0x-starter-project.
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.
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.
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.
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.
If i try to connect with Ledger too will the above code work
from 0x-starter-project.
You will need to use the Ledger subprovider to connect the ledger. There is a Ledger example in our wiki.
from 0x-starter-project.
ok ..
How to auto refresh if connected with metamask, metamask logged out account change and order place balance decrement
from 0x-starter-project.
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
from 0x-starter-project.
Related Issues (20)
- How to lock the token HOT 12
- how to reterive the locked and unloked token details HOT 2
- How to Change to Token Balance automactically if Account changes in Metamask HOT 1
- Missing code for validating order is fillable before calling fillOrder HOT 1
- [Q] What is color theme of this console? HOT 1
- How to get the data if Error: MetaMask Tx Signature: User denied transaction signature. HOT 10
- Mainnet rpcUrl HOT 1
- 0x protocol version 2 Get token by symbol HOT 1
- not works with mainnet
- Fill order HOT 1
- Fetch Transaction Notification from Metamask HOT 1
- insufficient balance error notify to user HOT 1
- [Question] How to finish the trade with ETH not WETH for maker and taker?
- Relayer fees in percentage
- Failed to install dependencies HOT 1
- Action required: Greenkeeper could not be activated 🚨
- Error: INSUFFICIENT_TAKER_FEE_ALLOWANCE HOT 1
- How was the ganache snapshot generated? HOT 1
- By placing an order facing issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 0x-starter-project.