Skip to main content
Version: V1

Bidirectional Connections

Bidirectional Connections API is used to query fields of bidirectional connections between a given address and another address or a list of other addresses (50 max).

You can find the step by step instructions on how to set up GraphQL client in your application and write a simple Get Bidirectional Connection query in the Read Connections section.

Structure

The general pattern of Bidirectional Connection query is:

biConnections(fromAddr String!, toAddrList [String!]!, network Network) [BidirectionalConnection!]!
FieldTypeDescriptionRequired/Optional
fromAddrString!The source address that you want to query bidirectional connections aboutRequired
toAddrList[String!]!A string list of addresses that you want to check if they have bidirectional connections with fromAddrRequired
networkNetworkThe blockchain network of the address you are querying aboutOptional. Default value is ETH.

With correct inputs, you will get a list of BidirectionalConnection objects, consisting of the following fields:

FieldTypeDescription
fromAddr StringThe source address that you want to query bidirectional connections about
toAddrStringAn address that is given in toAddrList
state BiConnStateThe bidirectional connection state between fromAddr and toAddr.
directionDirectionThe direction of bidirectional connection state.
namespaceStringThe namespace of this connection
networkNetworkThe network that is given as the querying parameter
createdAtStringThe creation time of this connection
updatedAtStringThe latest update time of this connection
latestHashStringThe proof hash of this connection. Please see Proof of Connection for detail design and implementation
latestEventConnectionEventThe latest event of this connection including the proof. Please see Proof of Connection for detail design and implementation.
latestAnchorEventConnectionEventThe latest event of this connection which can be found on Arweave

For followStatus, there will be two boolean variables: isFollowed and isFollowing. For state, there will be four enum values: EMPTYPENDINGCONNECTD and BLACKLIST. Our protocol defines a state machine to show relationship among these states and different bidirectional connection:

You also need direction to determine final state between fromAddr and toAddr, there will be three enum values: BIDIRECTIONFROM_TO and TO_FROM.

If state is EMPTY, the direction should be BIDIRECTION, it means the initial state between fromAddr and toAddr.

if state is PENDING, the direction can either be FROM_TO or TO_FROM, it means the direction of request sent from fromAddr to toAddr or from toAddr to fromAddr.

If state is CONNECTED, the direction should be BIDIRECTION, it means the bidirectional connection has been connected for both fromAddr and toAddr.

If state is BLACKLIST, the direction can either be BIDIRECTION, FROM_TO or TO_FROM, it means mutually block or the direction of block.

Examples

Fetch Proof Example

This is an example of a query to fetch proof data that you can also test out in the Playground:

query ProofQuery {
bidirectionalConnections(
fromAddr: "0xd45D6496DC32AA91E069C1D7870C5363bC5c8Fbd"
toAddrList: ["0xC76fbE40144ac56822C651B6e02497D4A576F23d"]
network: ETH
) {
from
to
latestEvent {
...event
}
latestAnchorEvent {
...event
}
}
}

fragment event on BiConnEvent {
hash
parentHash
fromAddr
toAddr
network
namespace
createdAt
isAnchor
proof {
content
digest
signature
signingKey
signingKeyAuth {
message
signature
address
}
arweaveTxHash
}
instruction
}

Fetch State Example

This is an example of a query to fetch the state and direction that you can also test out in the Playground:

query StateQuery {
bidirectionalConnections(
fromAddr: "0xd45D6496DC32AA91E069C1D7870C5363bC5c8Fbd",
toAddrList:["0xc76fbe40144ac56822c651b6e02497d4a576f23d"],
network: ETH) {
from
to
state
direction
}
}

Full Example

This is a full example for the Bidirectional Connections query that you can also test out in the Playground With arweaveTxHash you can query it on Arweave to proof the connection.

query BidirectionalConnectionsQuery {
bidirectionalConnections(
fromAddr: "0xd45D6496DC32AA91E069C1D7870C5363bC5c8Fbd",
toAddrList:["0xC76fbE40144ac56822C651B6e02497D4A576F23d"],
network: ETH) {
from
to
network
state
direction
namespace
updatedAt
latestEvent {
...event
}
latestAnchorEvent {
...event
}
}
}

fragment event on BiConnEvent {
hash
parentHash
fromAddr
toAddr
network
namespace
createdAt
isAnchor
proof {
content
digest
signature
signingKey
signingKeyAuth {
address
message
signature
}
arweaveTxHash
}
instruction
}
Designed by