Cami Ramos
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Fuel GraphQL API Documentation ## Overview ### Introduction to the Fuel GraphQL API The Fuel GraphQL API allows you to query the Fuel blockchain for a wide range of on-chain data. It can be used to query transactions, balances, block information, and more. You can also use it to simulate and submit transactions on the Fuel network. ### Playground The playground is an interactive and graphical IDE that includes a reference for queries, mutations, and types. It also provides query validation and context for the underlying GraphQL schema. You can test out the Fuel GraphQL API playground here: Beta-2 *(latest testnet)*: https://node-beta-2.fuel.network/playground Beta-1 *(first testnet)*: https://node-beta-1.fuel.network/playground You can learn more about the differences between the two networks [here](https://fuellabs.github.io/fuel-docs/master/networks/networks.html). ## GraphQL Spec ### HTTP and APIs Explained HTTP is a protocol, or a definite set of rules, for accessing resources on the web. Resources could mean anything from HTML files to data from a database, photos, text, and so on. These resources are made available to us via an Application Programming Interface (API) and we make requests to these APIs via the HTTP protocol. It is the mechanism that allows developers to request resources. Read more about HTTP methods, client-server architecture, and why you need APIs [here](https://www.freecodecamp.org/news/http-request-methods-explained/). ### What is GraphQL? >Note: This section goes over how GraphQL works under the hood, but it is not necessary to know this as a developer building on Fuel. Schema definition, resolver logic, etc. are all written and maintained by the contributors at Fuel Labs. GraphQL is a query language and specification that describes how you can communicate with your API. GraphQL is not constrained by programming languages, backend frameworks, and databases. GraphQL uses the HTTP protocol under the hood, so you can map GraphQL operations back to simple `GET`, `POST`, `PUT`, or `DELETE` operations. You can view the GraphQL documentation here: https://graphql.org/. A GraphQL API works by defining types and the properties available on those types, also known as the schema, and defining functions that specify the logic for how to resolve those types. A resolver is a function that's responsible for populating the data for a single field in your schema. Whenever a client queries for a particular field, the resolver for that field fetches the requested data from the appropriate data source. For example, as an API developer you could define a type, `Car` and define the properties that will be query-able on that type such as below: ```graphql type Car { id: ID color: String year: Int isNew: Boolean } ``` Fuel Labs created a GraphQL API endpoint for the Fuel Network, allowing developers to make complex queries for data on the blockchain. You can leverage these queries to populate a frontend application with details that your users might be interested in like the history of their transactions, their balance of a specific token, etc. ### GraphQL Queries Queries in GraphQL allow you to read data. GraphQL lets you ask for specific data and returns exactly what you asked for. It also lets you request multiple resources in a single query instead of writing a separate 'GET' request for each resource as with REST APIs. GraphQL also facilitates more complex queries and operations such as pagination, sort, filter, full-text search, and more. Sample query: ```graphql query Actor { actor { name { appearIn } } } ``` The above query gives you a response with the name of the actor along with the name of the movie(s) they appear in. ### GraphQL Mutations Mutations in GraphQL are write operations that update the chain's state. In addition to being able to traverse objects and their fields, GraphQL gives developers the ability to pass arguments to fields in order to filter out responses. Every field and nested object can have its own set of arguments. Sample mutation: ```graphql mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) { createReview(episode: $ep, review: $review) { stars commentary } } ``` ### GraphQL Schema & Type System Unlike traditional REST APIs, GraphQL comes with a strong type system to describe your API. A GraphQL schema describes the data you can query using the API endpoint by defining a set of types and fields that are mapped to those types. Read along to learn about various GraphQL types. #### Object Types Object types in GraphQL describe an object with underlying fields that can be queried from your API endpoint. As an example, an object type can be defined as shown below: ```graphql type actors { name: String! appearsIn: [movie!]! } ``` Here,`actors` is an object type and `name` and `appearsIn` are fields mapped to type `actors`. #### Scalar Types >From The GraphQL Documentation: In the example for object types above, field `name` is of type `String`. String in GraphQL is by default a scalar type. This means that it resolves to a definite value and cannot have further sub-fields while querying. Scalar types represent the leaves of a query. GraphQL comes with a set of default scalar types out-of-the-box such as below: - `Int`: A signed 32‐bit integer. - `Float`: A signed double-precision floating-point value. - `String`: A UTF‐8 character sequence. - `Boolean`: true or false. - `ID`: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable. Fields can also be of types that are not scalar by default, but resolve to scalar values upon querying. For instance, in the following query, the `name` and `appearsIn` fields resolve to scalar types. ```gql= { hero { name appearsIn } } ``` This is because in the schema, `name` and `appearIn` do not have further queryable sub-fields as described below: ```gql= { "data": { "hero": { "name": "R2-D2", "appearsIn": [ "NEWHOPE", "EMPIRE", "JEDI" ] } } } ``` #### Lists and Non-nulls >From the GraphQL documentation: Object types, scalars, and enums are the only kinds of types you can define in GraphQL. But when you use the types in other parts of the schema, or in your query variable declarations, you can apply additional type modifiers that affect validation of those values. Let's look at an example: ```gql type Character { name: String! appearsIn: [Episode]! } ``` Here, we're using a String type and marking it as Non-Null by adding an exclamation mark `!` after the type name. This means that our server always expects to return a non-null value for this field, and if it ends up getting a null value that will actually trigger a GraphQL execution error, letting the client know that something has gone wrong. The Non-Null type modifier can also be used when defining arguments for a field, causing the GraphQL server to return a validation error if a null value is passed either in the GraphQL string or the variables. ```gql= query DroidById($id: ID!) { droid(id: $id) { name } } { "id": null } ``` ```gql { "errors": [ { "message": "Variable \"$id\" of non-null type \"ID!\" must not be null.", "locations": [ { "line": 1, "column": 17 } ] } ] } ``` ``` gql myField: [String!] ``` This means that the list itself can be null, but it can't have any null members. For example, in JSON: ```json myField: null // valid myField: [] // valid myField: ['a', 'b'] // valid myField: ['a', null, 'b'] // error ``` #### Union types When a query returns a union type, you can use `... on` to specify the query fields for a certain return type. These are also called inline fragments. For example, the `hero` query below returns a union type of either `Droid` or `Human`. ```graphql query HeroForEpisode($ep: Episode!) { hero(episode: $ep) { name ... on Droid { primaryFunction } ... on Human { height } } } ``` #### Connections Connections are a type of response used whenever you are expecting multiple results that may require pagination. Each query return type that ends in "Connection" will include the following return fields: ```graphql pageInfo: PageInfo! edges: [SomethingEdge!]! nodes: [Something!]! ``` ##### PageInfo `pageInfo` returns an object that includes information about the returned page of results: `hasPreviousPage: Boolean!` Whether or not the result has a previous page. `hasNextPage: Boolean!` Whether or not the result has another page after it. `startCursor: String` The starting cursor that identifies the first page. `endCursor: String` The end cursor that identifies the last page. ##### Edges `edges` returns an array of edge objects, which includes the cursor and first node for that page. You can use this data to help with pagination. ##### Nodes `nodes` returns an array of whichever type you are expecting paginated results for. ##### Arguments Each of these queries also accepts the following arguments: `first: Int` `after: String` `last: Int` `before: String` `first` and `last` both accept an integer, which sets the number of results returned for each page. `first` will paginate the results starting at the beginning, while `last` will start from the end. It is required to pass an argument for either `first` or `last`. If no argument is given, the query will not return any results. `after` and `before` both accept a cursor, which you can use to request different pages. These are both optional arguments. You can learn more about the connection model and pagination in the official GraphQL docs here: https://graphql.org/learn/pagination/ ## Recipes ### Get an asset balance of an address ```graphql query Balance ($address: Address, $assetId: AssetId) { balance (owner: $address, assetId: $assetId) { owner amount assetId } } ``` ### List all asset balances of an address ```graphql query Balances($filter: BalanceFilterInput){ balances(filter: $filter, first: 5){ nodes { amount assetId } } } ``` ### List all transactions from an address ```graphql query Transactions($address: Address) { transactionsByOwner(owner: $address, first: 5) { nodes { id inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contract { id } } ... on InputMessage { messageId sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on MessageOutput { recipient amount } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract { id } stateRoot } } status { __typename ... on FailureStatus { reason programState { returnType } } } } } } ``` ### List the latest transactions ```graphql query LatestTransactions { transactions(last: 5) { nodes { id inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contract { id } } ... on InputMessage { messageId sender recipient amount owner data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on MessageOutput { recipient amount } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract { id } stateRoot } } status { __typename ... on FailureStatus { reason programState { returnType } } } } } } ``` ### Get an asset balance of a contract ```graphql query ContractBalance($contract: ContractId, $asset: AssetId) { contractBalance(contract: $contract, asset: $asset) { contract amount assetId } } ``` ### List all asset balances of a contract ```graphql query ContractBalances($filter: ContractBalanceFilterInput!) { contractBalances(filter: $filter, first: 5) { nodes { amount assetId } } } ``` ### List the latest blocks ```graphql query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contract { id } } ... on InputMessage { messageId sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on MessageOutput { recipient amount } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract { id } stateRoot } } gasPrice } } } } ``` ### Get block information by height ```graphql query Block($height: U64) { block(height: $height) { id } } ``` ### List all messages owned by address ```graphql query MessageInfo($address: Address) { messages(owner: $address, first: 5) { nodes { amount sender recipient nonce data daHeight fuelBlockSpend } } } ``` ### Dry run a transaction ```graphql mutation DryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) { dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) { receiptType data rawPayload } } ``` ### Submit a transaction ```graphql mutation submit($encodedTransaction: HexString!) { submit(tx: $encodedTransaction) { id } } ``` ### More Examples You can find more examples of how we use this API in our GitHub: [Block Explorer](https://github.com/FuelLabs/block-explorer-v2/) [Fuels Typescript SDK](https://github.com/FuelLabs/fuels-ts/) ## Reference ### Scalars #### `Address` An address of an externally owned account identified by a 32 byte string prefixed by `0x`. #### `AssetId` A 32 byte unique ID used to identify a coin. On the testnet, the assetId is `0x0000000000000000000000000000000000000000000000000000000000000000`. #### `BlockId` A unique hash identifier for a block. #### `Bytes32` 32 bytes to hold arbitrary data, usually as a hex string. `Bytes32` is the base type for cryptographic primitives like `Address` or `Message`. #### `ContractId` A wrapped 32byte hash that is used to uniquely identify a contract. #### `HexString` A way to pass in bytes as hex data. This is used for variable byte length types. Predicates and predicate data are always a hex string. #### `MessageId` A 32 byte identifier for cross-network messages, like messages from Ethereum to Fuel. #### `Salt` Sometimes referred to as a nonce. A unique, random value used to distinguish two things that are otherwise identical. This is used in contract deployments so you can deploy contracts that are otherwise exactly the same. #### `Tai64Timestamp` *(beta-2 only)* A TAI 64 timestamp. #### `TransactionId` A unique 32 byte hash identifier for a transaction. #### `TxPointer` The location of the transaction in the block. It can be used by UTXOs as a reference to the transaction or by the transaction itself to make it unique. #### `U64` Unsigned 64 bit number. The default GraphQL `int` scalar does not cover the range of values needed because the FuelVM word size is 64bit. #### `UtxoId` A unique 32 byte identifier for a UTXO. > #### `DateTime` *(beta-1 only)* > A TAI 64 timestamp. --- ### Enums #### `CoinStatus` The status of a UXTO, either `SPENT` or `UNSPENT` #### `ReceiptType` The receipt type inidicating what kind of transaction generated the receipt. `CALL` The receipt was generated from a contract call. `RETURN` The receipt was generated from a transaction that returned without data. `RETURN_DATA` The receipt was generated from a transaction that returned data. `PANIC` The receipt was generated from a failed contract call that panicked. `REVERT` The receipt was generated from a failed contract call that reverted. `LOG` The receipt was generated from a log in the contract. The Log receipt is generated for non-reference types, namely bool, u8, u16, u32, and u64. `LOG_DATA` The receipt was generated from a log in the contract. LogData is generated for reference types which include all types except for the non_reference types mentioned above. `TRANSFER` The receipt was generated from a transaction that transferred coins to a contract. `TRANSFER_OUT` The receipt was generated from a transaction that transferred coins to an address (rather than a contract). `SCRIPT_RESULT` The receipt was generated from a script. `MESSAGE_OUT` The receipt was generated from a message. #### `ReturnType` The type of return response for a transaction `RETURN` Indicates the transaction returned without any data. `RETURN_DATA` Indicates the transaction returned some data. `REVERT` Indicates the transaction reverted. --- ### Union Types #### `Input` An input type for a transaction. Types: `InputCoin` An input type for a coin. `InputContract` An input type for a contract. `InputMessage` An input type for a message. #### `Output` An output type for a transaction. Types: `CoinOutput` Indicates coins were forwarded from one address to another. `ContractOutput` Indicates the transaction updated the state of a contract. `MessageOutput` Indicates a message output. `ChangeOutput` Indicates that the output's amount may vary based on transaction execution, but is otherwise identical to a Coin output. Output changes are always guaranteed to have an amount of zero since they're only set after execution terminates. `VariableOutput` Similar to `ChangeOutput`, this output type indicates that the output's amount may vary based on transaction execution, but is otherwise identical to a Coin output. On initialization, the amount on variable outputs is zero, but during execution they could be set to a non-zero value. `ContractCreated` Indicates a contract was deployed. #### `TransactionStatus` The status type of a transaction. `SubmitedStatus` The transaction has been submitted. `SucessStatus` The transaction has succeeded. `SqueezedOutStatus` *(beta-2 only)* The transaction was kicked out of the mempool. `FailureStatus` The transaction has failed. --- ### Objects #### `Balance` The balance of a particular asset for a wallet address. fields: `owner: Address!` An EOA account represented by 32 bytes. `amount: U64!` The amount of the selected asset id as an unsigned 64 bit number. `assetId: AssetId!` A 32 byte representation of the asset. #### `BalanceFilterInput` The filter input type used to filter the `balances` query. fields: `owner: Address!` The owner address of the balances. #### `Block` Information about a block in the network. fields: `id: BlockId!` A unique identifier for the block. `header: Header!` *(beta-2 only)* Metadata about a block. `transactions: [Transaction!]!` An array of transactions included in the block. > `height: U64!` *(beta-1 only)* The total number of blocks on the chain. >`time: DateTime!` *(beta-1 only)* The timestamp when the block was produced. >`producer: Address!` *(beta-1 only)* The address of the block producer. #### `ChainInfo` Information about the base chain. At a very high level `chainInfo` helps you understand what Fuel chain you're connected to and the different parameters of this chain. fields: `name: String!` The human-readable string name of the chain. i.e. beta-2 `latestBlock: Block!` The most recently created block. `baseChainHeight: U64!` Returns 0 (in development mode, this will change). This should return the height of the chain at start. `peerCount: Int!` The number of nodes that node is peered with. `consensusParameters: ConsensusParameters!` The consensus parameters used to validate blocks. #### `ChangeOutput` A transaction output that changes the unspent coins in a UTXO. fields: `to: Address!` The recipient address of the coins. `amount: U64!` The amount of coins. `assetId: AssetId!` The asset id for the coins. #### `Coin` Information about a coin. fields: `utxoId: UtxoId!` A unique 32 byte identifier for a UTXO. `owner: Address!` The owner address of the coins. `amount: U64!` The amount of coins. `assetId: AssetId!` The asset id of the coin. `maturity: U64!` The UTXO being spent must have been created at least this many blocks ago. `status: CoinStatus!` The status of the coin, either `SPENT` or `UNSPENT`. `blockCreated: U64!` The block when the coins were created. <!-- #### `CoinFilterInput` The filter input type for the coinsToSpend query. It is required to specify either the `owner` or `assetId`. fields: `owner: Address!` The owner address of the coins. `assetId: AssetId` The asset id of the coins. --> #### `CoinOutput` A type representing a coin output. fields: `to: Address!` The receiver address of the output coins. `amount: U64!` The amount of coins in the output. `assetId: AssetId!` The asset id for the output coins. #### `ConsensusParameters` The consensus parameters used for validating blocks. fields: `contractMaxSize: U64!` The maximum contract size, in bytes. `maxInputs: U64!` The maximum number of inputs. `maxOutputs: U64!` The maximum number of outputs. `maxWitnesses: U64!` The maximum number of witnesses. `maxGasPerTx: U64!` The maximum gas per transaction. `maxScriptLength: U64!` The maximum length of a script, in instructions. `maxScriptDataLength: U64!` The maximum length of script data, in bytes. `maxStorageSlots: U64!` The maximum number of initial storage slots. `maxPredicateLength: U64!` The maximum length of a predicate, in instructions. `maxPredicateDataLength: U64!` The maximum length of predicate data, in bytes. `gasPriceFactor: U64!` A factor to convert between gas and the transaction assets value. `gasPerByte: U64!` A fixed ratio linking metered bytes to a gas price. `maxMessageDataLength: U64!` The maximum length of message data, in bytes. #### `Contract` An object representing a deployed contract. fields: `id: ContractId!` The contract address. `bytecode: HexString!` The contract bytecode. `salt: Salt!` A unique identifier for the contract. #### `ContractBalance` An object representing the balance of a deployed contract for a certain asset. fields: `contract: ContractId!` The contract address. `amount: U64!` The contract balance for the given asset. `assetId: AssetId!` The asset id for the coins. #### `ContractBalanceFilterInput` The filter input type for the `contractBalances` query. fields: `contract: ContractId!` The contract id that the query will return balances for. #### `ContractCreated` The output type from deploying a contract. fields: `contract: Contract!` The contract that was created. `stateRoot: Bytes32!` The initial state root of contract. #### `ContractOutput` The output type from a transaction that changed the state of a contract. fields: `inputIndex: Int!` The index of the input. `balanceRoot: Bytes32!` The root of amount of coins owned by contract after transaction execution. `stateRoot: Bytes32!` The state root of contract after transaction execution. #### `FailureStatus` The status type of a transaction that has failed. fields: `block: Block!` The block number for the failed transaction. `time: Tai64Timestamp!` The time the transaction failed. Returns a `DateTime!` for the beta-1 network. `reason: String!` The reason why the transaction failed. `programState: ProgramState` The state of the program execution. #### `Header` *(beta-2 only)* The header contains metadata about a certain block. `id: BlockId!` The current block id. `daHeight: U64!` The block height for the data availability layer up to which (inclusive) input messages are processed. `transactionsCount: U64!` The number of transactions in the block. `outputMessagesCount: U64!` The number of output messages in the block. `transactionsRoot: Bytes32!` The merkle root of the transactions in the block. `outputMessagesRoot: Bytes32!` The merkle root of the output messages in the block. `height: U64!` The block height. `prevRoot: Bytes32!` The merkle root of all previous consensus header hashes (not including this block). `time: Tai64Timestamp!` The timestamp for the block. `applicationHash: Bytes32!` The hash of the serialized application header for this block. #### `InputCoin` Information about a coin input. fields: `utxoId: UtxoId!` A unique 32 byte identifier for the UTXO. `owner: Address!` The owning address or predicate root. `amount: U64!` The amount of coins. `assetId: AssetId!` The asset ID of the coins. `txPointer: TxPointer!` A pointer to the transaction whose output is being spent. `witnessIndex: Int!` The index of the witness that authorizes spending the coin. `maturity: U64!` The UTXO being spent must have been created at least this many blocks ago. `predicate: HexString!` The predicate bytecode. `predicateData: HexString!` The predicate input parameters. #### `InputContract` Information about a contract input. fields: `utxoId: UtxoId!` A unique 32 byte identifier for the UTXO. `balanceRoot: Bytes32!` The root of amount of coins owned by contract before transaction execution. `stateRoot: Bytes32!` The state root of contract before transaction execution. `txPointer: TxPointer!` A pointer to the TX whose output is being spent. `contract: Contract!` The input contract. #### `InputMessage` Information about a message input. fields: `messageId: MessageId!` A unique id for the message. The ID of a message is computed as the hash of: - the sender address as byte[32], - the recipient address as byte[32], - the Message nonce as byte[32], - the amount being sent with the message as uint64, - the message data as byte[] `sender: Address!` The sender address of the message. `recipient: Address!` The recipient address of the message. `amount: U64!` The amount sent in the message. `nonce: U64!` A nonce value for the message input, which is determined by the sending system and is published at the time the message is sent. `witnessIndex: Int!` The index of witness that authorizes spending the coin. `data: HexString!` The message data. `predicate: HexString!` The predicate bytecode. `predicateData: HexString!` The predicate input parameters. >`owner: Address!` *(beta-1 only)* The owner address of the message. #### `Message` Contains information about a message. fields: `messageId: MessageId!` *(beta-2 only)* A unique id for the message. `amount: U64!` The amount of base asset coins sent with the message. `sender: Address!` The address of the message sender. `recipient: Address!` The recipient of the message. `nonce: U64!` The nonce value for the message. `data: [Int!]!` The vector with the message data. `daHeight: U64!` The block height of the data availability layer up to which (inclusive) input messages are processed. `fuelBlockSpend: U64` The block in which the message is spent. >`owner: Address!` *(beta-1 only)* The owner address of the message. #### `MessageOutput` The output type for a message. When signing a transaction recipient and amount are set to zero. When verifying a predicate or executing a script, recipient and amount are initialized to zero. fields: `recipient: Address!` The recipient of the message. `amount: U64!` The amount of base asset coins sent with the message. #### `MessageProof` Information about the message proof. `proofSet: [Bytes32!]!` The proof set of the message proof. `proofIndex: U64!` The index used to generate this proof. `sender: Address!` The message sender. `recipient: Address!` The message recipient. `nonce: Bytes32!` The message nonce. `amount: U64!` The amount sent in the message. `data: HexString!` The data from the message. `signature: Signature!` The signature of the Fuel block. `header: Header!` The Fuel block header that contains the message. #### `NodeInfo` Information about a node. fields: `utxoValidation: Boolean!` Whether or not the node is using UTXO validation. `vmBacktrace: Boolean!` Whether or not logging of backtraces from VM errors is enabled. `minGasPrice: U64!` The minimum gas price for the node. `maxTx: U64!` The maximum number of transactions. `maxDepth: U64!` The maximum number of connected UTXOs allowed, excluding contracts. `nodeVersion: String!` The node version. >`predicates: Boolean!` *(beta-1 only)* Whether or not predicates are enabled. #### `ProgramState` An object representing the state of execution of a transaction. fields: `returnType: ReturnType!` The type of return response for the transaction. `data: HexString!` The data returned from the transaction. #### `Receipt` An object representing all possible types of receipts. `contract: Contract` The contract that produced the receipt. `pc: U64` The value of the program counter register `$pc`, which is the memory address of the current instruction. `is: U64` The value of register `$is`, which is the pointer to the start of the currently-executing code. `to: Contract` The recipient contract. `toAddress: Address` The recipient address. `amount: U64` The amount of coins transferred. `assetId: AssetId` The asset id of the coins transferred. `gas: U64` The gas used for the transaction. `param1: U64` The first parameter for a `CALL` receipt type, holds the function selector. `param2: U64` The second parameter for a `CALL` receipt type, typically used for the user-specified input to the ABI function being selected. `val: U64` The value of registers at the end of execution, used for debugging. `ptr: U64` The value of the pointer register, used for debugging. `digest: Bytes32` A 32-byte hash of `MEM[$rC, $rD]`. The syntax `MEM[x, y]` means the memory range starting at byte `x`, of length `y` bytes. `reason: U64` The decimal string representation of an 8-bit unsigned integer for the panic reason. Only returned if the receipt type is `PANIC`. `ra: U64` The value of register `$rA`. `rb: U64` The value of register `$rB`. `rc: U64` The value of register `$rC`. `rd: U64` The value of register `$rD`. `len: U64` The length of the receipt. `receiptType: ReceiptType!` The type of receipt. `rawPayload: HexString!` The raw payload hex string. `result: U64` `0` if script exited successfully, `any` otherwise. `gasUsed: U64` The amount of gas consumed by the script. `data: HexString` The receipt data. `messageId: MessageId` The message id. `sender: Address` The address of the message sender. `recipient: Address` The address of the message recipient. `nonce: Bytes32` The nonce value for a message. `contractId: ContractId` *(beta-2 only)* The contract id. #### `SpendQueryElementInput` A type used in the `queryPerAsset` argument for the `resourcesToSpend` query. `assetId: AssetId!` The asset id for the asset. `amount: U64!` The amount of coins to send. `max: U64` *(beta-2 only)* The max number of resources in the selection. #### `SubmittedStatus` The status for a submitted transaction fields: `time: Tai64Timestamp!` The time a transaction was submitted. Returns a `DateTime` for the beta-1 network. #### `Transaction` An object containing information about a transaction. fields: `id: TransactionId!` A unique transaction id. `inputAssetIds: [AssetId!]` An array of asset ids used for the transaction inputs. `inputContracts: [Contract!]` An array of contracts used for the transaction inputs. `gasPrice: U64` The gas price for the transaction. `gasLimit: U64` The gas limit for the transaction. `maturity: U64` The minimum block height that the transaction can be included at. `txPointer: TxPointer` *(beta-2 only)* The location of the transaction in the block. `isScript: Boolean!` Whether or not the transaction is a script. `isCreate: Boolean!` *(beta-2 only)* Whether or not the transaction is creating a new contract. `isMint: Boolean!` *(beta-2 only)* Whether or not the transaction is minting new coins. `inputs: [Input!]` An array of inputs for the transaction. `outputs: [Output!]!` An array of outputs for the transaction. `witnesses: [HexString!]` An array of witnesses. `receiptsRoot: Bytes32` The root of the receipts. `status: TransactionStatus` The status of the transaction. `receipts: [Receipt!]` An array of the receipts produced by the transaction. `script: HexString` The script to execute. `scriptData: HexString` The script input parameters. `bytecodeWitnessIndex: Int` The witness index of contract bytecode. `bytecodeLength: U64` The length of the transaction bytecode. `salt: Salt` The salt value for the transaction. `storageSlots: [HexString!]` An array of storage slot. `rawPayload: HexString!` A hex string of the raw transaction payload. #### `VariableOutput` The output type for a transaction that outputs an amount that may vary based on transaction execution. fields: `to: Address` The address the coins were sent to. `amount: U64` The amount of coins in the output. `assetId: AssetId` The asset id for the coins sent. --- ### Queries #### `balance(...): Balance!` Returns the balance of a specific address for a given asset id. args: `owner: Address!` The owner address. `assetId: AssetId!` The asset id. #### `balances(...): BalanceConnection!` Returns a connection for an array of balances for each asset owned by a given address. args: `filter: BalanceFilterInput!` A filter to specify the wallet owner address. #### `block(...): Block` Returns information about a certain block. Accepts either the block id or block height as an argument. args: `id: BlockId` The block id. `height: U64` The block height. #### `blocks(...): BlockConnection!` Returns a connection for an array of all blocks produced. #### `chain: ChainInfo!` Returns information about the target Fuel network used for the API. #### `transaction(...): Transaction` Returns transaction details for a given transaction id. args: `id: TransactionId!` The id for the transaction. #### `transactions(...): TransactionConnection!` Returns a connection for an array of all transactions. #### `transactionsByOwner(...): TransactionConnection!` Returns a connection for an array of all transactions from a given address. args: `owner: Address!` The owner address of the transactions. #### `health: Boolean!` Returns `true` if the API is running or `false` if the API is down. #### `coin(...): Coin` Returns details about a specific coin. args: `utxoId: UtxoId!` A unique 32 byte identifier for the UTXO. #### `coins(...): CoinConnection!` Returns a connection for an array of coins based on a given owner and/or asset id args: `filter: CoinFilterInput!` A filter with the owner address and optionally the asset id. #### `contract(...): Contract` Returns the contract information for a given contract id. args: `id: ContractId!` The contract id of the requested contract. #### `contractBalance(...): ContractBalance!` Returns the balance for a given contract and asset id. args: `contract: ContractId!` The contract that owns the balance. `asset: AssetId!` The asset id for the balance. #### `contractBalances(...): ContractBalanceConnection!` Returns a connection for an arrray of balances for all assets owned by a given contract args: `filter: ContractBalanceFilterInput!` A filter for the contract balances. #### `nodeInfo: NodeInfo!` Returns information about the current node. #### `messages(...): MessageConnection!` Returns a connection for an array of messages for a given owner. args: `owner: Address` The owner address of the messages. #### `messageProof(...): MessageProof` *(beta-2 only)* args: `transactionId: TransactionId!` The transaction id for the message. `messageId: MessageId!` The id of the message. #### `resourcesToSpend(...): [[Resource!]!]!` *(beta-2 only)* Returns the list of spendable resources per asset from the query. The length of the result is the same as the length of `query_per_asset`. The ordering of assets and `query_per_asset` is the same. args: `owner: Address!` The address to send coins to. `queryPerAsset: [SpendQueryElementInput!]!` The list of requested asset resources. Several entries with the same asset id are not allowed. `excludedIds: ExcludeInput` The resources to exclude. ### Mutations #### `dryRun(...): [Receipt!]!` A mutation that spins up a new temporary node from the current state and emulates a given transaction. It returns an array of receipts for the emulated transaction. You can optionally use UTXO validation. args: `tx: HexString!` The transaction hex string. `utxoValidation: Boolean` Whether or not to use UTXO validation. #### `produceBlocks(...): U64!` A mutation that produces blocks, that can be used for testing that requires block advancement. args: `blocksToProduce: U64!` The number of blocks to produce. #### `submit(...): Transaction!` A mutation that submits transaction to the transaction pool and returns a transaction. args: `tx: HexString!` The transaction hex string. ### Subscriptions #### `statusChange(...): TransactionStatus!` *(beta-2 only)* Returns a stream of status updates for the given transaction id if the current status is `[TransactionStatus::Submitted]`. This stream will wait forever so it's advised to use within a timeout. It is possible for the stream to miss an update if it is polled slower then the updates arrive. In such a case the stream will close without a status. If this occurs the stream can simply be restarted to return the latest status. args: `id: TransactionId!` The id of the transaction to stream status updates for.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully