Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
const client = createDfuseClient({ apiKey: DFUSE_API_KEY, network: DFUSE_API_NETWORK })
try {
// This example will work on EOS Mainnet only, change transaction id accordingly to test it out
const response = await client.fetchTransaction(
"1d5f57e9392d045ef4d1d19e6976803f06741e11089855b94efcdb42a1a41253"
)
console.log("Transaction lifecycle response", prettifyJson(response))
} catch (error) {
console.log("An error occurred", error)
}
client.release()
}
async function main() {
const client = createDfuseClient({ apiKey: DFUSE_API_KEY, network: DFUSE_API_NETWORK })
const searchTransactions = `query ($limit: Int64!) {
searchTransactionsBackward(query: "auth:${account}", limit: $limit) {
results {
block { num }
trace { id matchingActions { json } }
}
}
}`
try {
const response = await client.graphql(searchTransactions, {
variables: { limit: 10 }
})
console.log()
console.log("Socket emitted an error event.", {
message: event.message,
error: event.error
})
},
onClose(event: any) {
console.log("Socket has closed its connection.", { reason: event.reason, code: event.code })
},
onReconnect() {
console.log("Socket has been reconnected with remote server.")
}
}
const client = createDfuseClient({
apiKey: DFUSE_API_KEY,
network: DFUSE_API_NETWORK,
streamClientOptions: {
socketOptions
},
graphqlStreamClientOptions: {
socketOptions
}
})
const graphqlOperation = `subscription($cursor: String!) {
searchTransactionsForward(query: "action:onblock", cursor: $cursor) {
undo cursor
block { num timestamp }
}
}`
async function main() {
const client = createDfuseClient({
apiKey: DFUSE_API_KEY,
network: DFUSE_API_NETWORK
})
const stream = await client.streamHeadInfo((message: InboundMessage) => {
if (message.type === InboundMessageType.LISTENING) {
console.log(prettifyJson(message.data))
return
}
if (message.type === InboundMessageType.HEAD_INFO) {
console.log(prettifyJson(message.data))
return
}
})
async function main() {
const client = createDfuseClient({
apiKey: DFUSE_API_KEY,
network: DFUSE_API_NETWORK
})
try {
const response = (await client.graphql(printGraphqlDocument(searchTransferQuery), {
variables: { limit: 10 }
})) as GraphqlResponse
console.log(prettifyJson(response))
} catch (error) {
console.log("An error occurred", error)
}
client.release()
}
async function main() {
const client = createDfuseClient({ apiKey: DFUSE_API_KEY, network: DFUSE_API_NETWORK })
const query = `(ram.released:${account} OR ram.consumed:${account})`
try {
let resultCount = 0
let runningTotal = 0
let cursor = ""
let pageCount = 0
while (resultCount <= maxResults) {
const page = await fetchPage(client, query, cursor)
pageCount++
resultCount += page.transactions.length
cursor = page.cursor
page.transactions.forEach((result: SearchTransactionRow) => {
async function main() {
const client = createDfuseClient({
apiKey: DFUSE_API_KEY,
network: DFUSE_API_NETWORK,
streamClientOptions: {
socketOptions: {
reconnectDelayInMs: 250
}
}
})
const engine = new Engine(client)
await engine.start()
await waitFor(50000)
await engine.stop()
client.release()
async function main() {
const client = createDfuseClient({
apiKey: DFUSE_API_KEY,
network: DFUSE_API_NETWORK,
graphqlStreamClientOptions: {
socketOptions: {
reconnectDelayInMs: 250
}
}
})
const engine = new Engine(client)
await engine.run()
client.release()
}
async function main() {
const client = createDfuseClient({
apiKey: process.env.DFUSE_API_KEY!,
network: process.env.DFUSE_API_NETWORK || "mainnet",
httpClientOptions: {
fetch: nodeFetch
},
graphqlStreamClientOptions: {
socketOptions: {
webSocketFactory
}
},
streamClientOptions: {
socketOptions: {
webSocketFactory
}
}
})
export const initializeDfuseClientFromConfig = () => {
initializeDfuseClient(
createDfuseClient({
apiKey: Config.dfuse_io_api_key,
network: Config.dfuse_io_endpoint,
authUrl: Config.dfuse_auth_endpoint,
secure: Config.secure !== undefined && Config.secure
})
)
}