prberg
September 11, 2023, 10:10am
1
In a previous Q&A, @calldelegation shared the following example GraphQL query:
query {
balances(filter: { owner: "0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871" }, first: 5) {
nodes {
amount
assetId
}
}
}
I can see that the same address is used throughout the example queries in your GraphQL docs .
But this confuses me because the address format does not match what I see in my Fuel wallet, which is this:
fuel1s0cvmmdgpjmrc48vv306rcqmv2ug3ua0z0qj509ptewvvj864mvs08zs42
Passing this value in the GraphQL query results in an error:
{
"data": null,
"errors": [
{
"message": "Failed to parse \"Address\": Odd number of digits (occurred while parsing \"BalanceFilterInput\")",
"locations": [
{
"line": 2,
"column": 20
}
],
"path": [
"balances"
]
}
]
}
How am I supposed to convert my wallet’s Fuel address to the format expected by the GraphQL server?
2 Likes
prberg
September 11, 2023, 12:53pm
2
Based on the discussion here , I think I am getting it now.
What I need for the GraphQL query is the hex address, whereas the Fuel Wallet displays only the Bech32 address (and there’s no way to view the address as hex, unfortunately).
But it looks like I can export the private key using the Fuel Wallet. Is there any CLI tool that I can use for deriving the public key?
Edit : I tried to generate the public key using this browser-based ED25519 tool , but the generated value didn’t seem to match my actual address (the query returned a balance of zero, whereas I have ~0.449 ETH on Testnet Beta 3).
1 Like
Hi there!
You can use the TS sdk to get the hex address.
const wallet = await window.fuel.getWallet(account);
console.log("wallet: ", wallet.address, wallet.address.toHexString());
2 Likes
david
September 11, 2023, 3:41pm
4
I’ll add that our goal is to use Bech32 everywhere, but we’ve done a poor job at being consistent with it’s usage
The GraphQL RPC should definitely should have Bech32 support added to it.
2 Likes
cr-fuel
September 13, 2023, 2:21am
5
Hello @prberg , I am working on a crypto plugin for forc.
opened 02:55AM - 21 Mar 23 UTC
enhancement
forc
P: medium
Raised by @SilentCicero in slack.
The idea is to expose common-use fuel crypt… ographic functions like `sha256`, `keccak256`, `ecrecover` via forc plugin(s).
The original proposal was for a `forc utils` subcommand with a broader scope, though I'm thinking it could be worth having more descriptive plugins for each set of tools.
A forc-crypto plugin might include commands like the following:
- `forc crypto sha256 ...`
- `forc crypto keccak256 ...`
- `forc crypto ecrecover ...`
- `forc crypto bech32-to-hex ...`
- `forc crypto hex-to-bech32 ...`
Commands like `sha256` and `keccak256` should support both file and string arguments. The same likely goes for the ecrecover message.
The plugin should likely be shipped by `fuelup` as a part of the default set of components.
This plugin should go in its own repo, but we can use this issue to track until then.
Once that plugin is available, it would be possible to perform all the conversion that you need right at your cli.
2 Likes
system
Closed
October 3, 2023, 10:21pm
6
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.