connect()
This file documents the main exports of the library.

connect(location, connector, options)

Connects and returns an Organization for location.
Name
Type
Description
location
String
The Ethereum address or ENS domain of an Aragon organization.
connector
Connector or [String, Object] or String
Accepts a Connector instance, and either a string or a tuple for embedded connectors and their config.
options
Object
The optional configuration object.
options.ethereum
EthereumProvider
An EIP-1193 compatible object.
options.network
The network to connect to. Defaults to 1.
options.ipfs
The IPFS gateway and cached results. Defaults to 'https://ipfs.eth.aragon.network/ipfs/{cid}{path}' and 40 respectively.
returns
Promise<Organization>
An Organization instance.
This function can throw the following errors:
Error type
Description
An unsupported or invalid connector was provided.
The Ethereum provider doesn’t seem to be valid.
The provided location doesn’t seem to be valid.
The network is incorrect or unsupported.

Example

1
import connect from '@aragon/connect'
2
3
// Connections should get wrapped in a try / catch to capture connection errors
4
try {
5
// Connect to an org through The Graph
6
const org1 = await connect('org1.aragonid.eth', 'thegraph')
7
8
// Specify a different Chain ID
9
const org3 = await connect('org3.aragonid.eth', 'thegraph', { network: 4 })
10
11
// Specify a configuration for the connector
12
const org3 = await connect('org3.aragonid.eth', [
13
'thegraph',
14
{ orgSubgraphUrl: 'http://…' },
15
])
16
17
// Custom connector
18
const org4 = await connect(
19
'org4.aragonid.eth',
20
21
// CustomConnector implements IConnector
22
new CustomConnector()
23
)
24
} catch (err) {
25
if (err instanceof ConnectionError) {
26
console.error('Connection error')
27
} else {
28
console.error(err)
29
}
30
}
Copied!
Last modified 5d ago