Skip to main content

Questions tagged [offchain-worker]

Oracle-like capabilities for Substrate chains.

Filter by
Sorted by
Tagged with
8 votes
2 answers
807 views

When does an off-chain worker get executed?

I have a scenario where I want to execute a scheduled call via the scheduler pallet at block number n. This call will change certain storage items of pallet. So before this storage changes, I want to ...
llvm_ninja's user avatar
7 votes
1 answer
188 views

Is it possible to query an OCW's Off-chain storage via RPC from an external service?

I'm off-chain indexing some pallet events into my off-chain local storage using an OCW. Now, I want to be able to retrieve this data via RPC from an external service. Is this possible? Does it require ...
Pablo Buitrago's user avatar
5 votes
2 answers
128 views

How to avoid multiple OCWs duplicating work?

We are running 2 OCWs each in separate instances and we have an extrinsic which mutates a storage in runtime which is done twice from the 2 OCWs but we want only one OCW to sign. How to do that? For ...
Immanuel John's user avatar
5 votes
2 answers
167 views

Is there any oracle solution available for substrate based solo chain?

We have a Substrate based solo chain where we need to fetch external data like ETH/USD price using off-chain workers right now. But these OCW doesn't work for reaching consensus on data being fetched ...
Immanuel John's user avatar
4 votes
2 answers
196 views

How to create a transaction that calls an offchain worker?

Is it possible to create a transaction that calls an offchain worker to write data to the offchain worker?
Joshua Aruokhai's user avatar
4 votes
2 answers
210 views

Read a value from offchain storage of a node

I want to read a single value from OffchainStorage of a live substrate node. Is it possible? Assume I can not use localStorageGet rpc request because it is an unsafe rpc.
Matt Duncan's user avatar
4 votes
1 answer
52 views

offchain-workers vs asynchronous task

There is not much info about using an asynchronous task in substrate docs i.e. task_manager in service.rs I want to know when one should be using offchain-worker and when one should use background ...
Rusty Pythonic Script's user avatar
4 votes
1 answer
130 views

Facing issue in adding offchain worker

I'm using pow substrate chain. I'm running 3 validators by using these commands: For bob ./target/release/node-template \ --base-path /tmp/bob \ --chain local \ --bob \ --port 30335 \ --rpc-port 9944 \...
Deepak Chaudhary's user avatar
4 votes
1 answer
50 views

Change state from a task

I have a asynchronous task running in service.spawn_essential_task(task). Which does some stuff and wants to write data in storage. How can i achieve this? Changing state by making runtime_apis to ...
Guest's user avatar
  • 43
4 votes
1 answer
157 views

How to verify that a signed payload of an unsigned extrinsic is signed by a local account?

I've been following the how-to guide to implementing unsigned extrinsic call with a signed payload. My pallet defines the following KeyTypeId: pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"ver!&...
digital illusion's user avatar
4 votes
0 answers
107 views

Accessing On-Chain Data In an Off-Chain Worker

I am looking to aggregate On-Chain data in an Off-Chain Worker, e.g. summing transaction fees included in blocks from the last 24 hrs. This is listed as one of the main use cases for Off-Chain Workers....
brendan's user avatar
  • 41
3 votes
2 answers
101 views

How can a OCW determine if a node is fully synced?

Is there a status-call/api that a OCW could invoke in order to establish if the actual running node instance is fully synced? Maybe listening to a frame_system event? Or knowing the total blocks ...
Pablo Buitrago's user avatar
3 votes
2 answers
152 views

Can I call external APIs inside my pallet?

How can I call external APIs from the chain then use that data to implement further logic
Sam Elamin's user avatar
  • 1,223
3 votes
1 answer
80 views

Can we enable off-chain workers http client to support web-sockets request?

As for now it supports rest request, and some duration limitation due to valid reasons. So my question is can we enable or work with web sockets for monitoring data changes , as for now we are only ...
Mrisho Lukamba's user avatar
3 votes
2 answers
129 views

Persistent Offchain Worker Storage

Offchain workers storage comes in two flavors: Persistent and Local. pub enum StorageKind { /// Persistent storage is non-revertible and not fork-aware. It means that any value /// set by the ...
Alejandro Martínez's user avatar
3 votes
1 answer
38 views

Is there a way to use a crate that depends on the `std` in substrate OCW?

from what I've learned so far, the OCW is designed specifically for executing heavy and time-consuming computations outside of the runtime. As the OCW is not a part of runtime/wasm, I guess the OCW ...
Yahor Tsaryk's user avatar
3 votes
1 answer
86 views

Offchain indexing storage overwrites during forks

We are using offchain indexing to store some value that will be read in offchain worker . The keys that we are using to store data via offchain indexing is as following: key = some_prefix + ...
Aramik M's user avatar
  • 139
3 votes
1 answer
75 views

Calling CLI subcommand through different terminal after running the node

I'm trying to set some off-chain storage through a different terminal using a custom subcommand after starting up the node. Question here is: Is there any way to call the custom CLI subcommand in the ...
Pawan Bisht's user avatar
3 votes
0 answers
24 views

Access protected API from off-chain worker

Is it possible to access a protected API from an off-chain worker, e.g. using an API Key? Hard coding the API Key would be possible, but that's obviously a security risk. Is there a safe mechanism to ...
Ronin's user avatar
  • 189
2 votes
2 answers
173 views

How to ensure call was made by Offchain Worker

Feels like a very newbie question but, whilst I've found hints of how to implement this, I can't find the recommended solution. I have an offchain worker that does some validation of remote data and ...
jpataylor's user avatar
  • 321
2 votes
1 answer
146 views

How can I create OCW that won't activates every block, but will activates only when I call function that it represents?

I wanna create OCW that will send a http request to the API and get the response and use this response in runtime code to call extrinsic with this data. This OCW should triggers only when I want to ...
Artem Levchuk's user avatar
2 votes
1 answer
130 views

Offchain Worker Not Initializing - Cumulus Parachain Template

I am observing unexpected behavior with the Cumulus Parachain Template. Our pallet uses off-chain workers (OCW), and the functionality successfully runs when we attach it to the Substrate Node ...
Brendan's user avatar
  • 65
2 votes
1 answer
265 views

Process ethereum transactions in an offchain worker

I need to process Ethereum transactions in a substrate offchain worker. I already include EVM and Ethereum pallets, but I also need to do some communications with runtime code running as solidity ...
naiem's user avatar
  • 123
2 votes
1 answer
67 views

How to fetch data through api?

I want to fetch the data through an api in our chain. More specifically, I have an api which gives me the latest news. How can i implement this in our substrate chain? can we have any doc or resources ...
Deepak Chaudhary's user avatar
2 votes
1 answer
92 views

AccountId in offchain worker

I'm working on Substrate based project. In the project, each blockchain validator has an offchain worker. author_insertKey() is used to set up a key so the offchain worker can sign transactions. Each ...
Maksim Ramanenkau's user avatar
2 votes
1 answer
85 views

Is it possible to write-access Local Storage from the Node?

My use case is this: an Offchain Worker sends Http requests to certain endpoints. These endpoints are hardcoded on chain under current implementation. I would like to be able to configure those ...
Yury Yukhananov's user avatar
2 votes
1 answer
98 views

Can an off-chain worker read/write the state of an EVM contract?

Let's assume we have a frontier-based node with smart contract X. From an off-chain worker, we want to call X.some_method() which will return data, and then the worker would use this data to make some ...
Adam Wierzbicki's user avatar
2 votes
1 answer
117 views

How to write unit tests for offchain workers?

Pallets can have unit tests with a mock runtime where extrinsics are tested against multiple cases. However it's not obvious how to do the same for offchain workers. How can I write unit tests for ...
Bernardo Rodrigues's user avatar
2 votes
1 answer
122 views

Only one node should make http call from OCW

I'm trying to figure out with OCW. And have a question is it possible to configure OCW so that if one node starts an HTTP call in OCW other nodes will skip it. I checked all examples I could find ...
Leu Barycheuski's user avatar
2 votes
1 answer
41 views

How to register a custom extension for offchain workers?

I have the following code. #[cfg(feature = "std")] use sp_externalities::ExternalitiesExt; #[cfg(feature = "std")] sp_externalities::decl_extension! { pub struct CustomExt(u32)...
Sachin's user avatar
  • 61
2 votes
1 answer
51 views

Calling external RPC method from OCW

I want to call an external RPC method from the offchain_worker. I checked multiple jsonrpc clients but none of them were no_std compatible. I want to know if there are any clients out there which can ...
StackedQ's user avatar
  • 131
2 votes
1 answer
36 views

Configure offchain worker with command line argument

Is configuring an off-chain worker with a command line argument possible? e.g. ./target/release/cere --dev --alice --my-custom-url "http://my-..." If not what are the other options?
Maksim Ramanenkau's user avatar
2 votes
1 answer
36 views

How to make a fn only callable by an offchain worker?

I don't think this is possible but is it? I have data that comes from an API that ultimately needs to be stored onchain which I don't want to risk having done through a Pays::No fn in case the call ...
bobby dy's user avatar
2 votes
0 answers
84 views

How should I add offchain worker(OCW) in frontier when using AccountId20?

In order to add an offchain worker with using AccountId20 as the runtime account type I did following things. add associated type type AuthorityId: AppCrypto<Self::Public, Self::Signature>; in ...
xiao liang's user avatar
2 votes
0 answers
31 views

Are onchain storage reads cheaper from offchain worker versus from extrinsic?

Are reads from offchain workers less expensive than reads from extrinsics? I am determining how to do some large, asynchronous processing of data and determining whether the reads in this process see ...
Justin Frevert's user avatar
2 votes
0 answers
85 views

Offchain cache/view of on-chain storage data

I am implementing a pallet, that stores in on-chain storage (aka StorageNMap's) some user provided data. Pallet is performing offchain computations by iterating on-chain storage from offchain-worker ...
Klapeyron's user avatar
  • 136
2 votes
1 answer
117 views

Working up-to-date complete source code for offchain workers?

Hello Substrate community I've been trying to integrate an offchain worker capable of API calls on top of an existing Substrate cluster of 3 nodes I already have up and running successfully (based on ...
PoCk3T's user avatar
  • 23
2 votes
1 answer
68 views

How to write a dispatch function which can only access from offchain worker with signed extrinsic/transaction?

I want to modify some on-chain storage from offchain worker by sending a signed transaction, so I write a dispatch function which handles the transaction. But the dispatch function also can be ...
kugool's user avatar
  • 171
1 vote
2 answers
135 views

How to comprehend the hooks of Substrate? Such as `on_initialize`, `on_finialize` and `offchain_worker`

I want to use hooks for some business logic, but I'm not very familiar with the usage of on_initialize, on_finialize and offchain_worker. Can all of them modify the on chain storage? If yes, what is ...
kugool's user avatar
  • 171
1 vote
1 answer
155 views

How to establish web socket connection in offchain_worker

Is there any way/example to establish web socket connection through off chain worker? There are many Rust examples but I can't use standard library. Can someone please help me?
Boleng's user avatar
  • 523
1 vote
1 answer
33 views

Would it be possible to make HTTP request on chain through pallet extrinsic?

We can make HTTP Get and Post request through Offchain worker. Can we also do the same on chain through pallet extrinsic? Is there any restriction?
Boleng's user avatar
  • 523
1 vote
1 answer
90 views

How to feed private data(confidential information) in Substrate chain through oracle?

Is there any Oracle solution available to feed private data to Substrate chain? Feeding data to chain has already been answered here How can I build a price feed oracle for my Substrate chain?. And ...
Boleng's user avatar
  • 523
1 vote
1 answer
55 views

Configure OCW to run every x blocks or on demand

I understand that off-chain workers are spawned during block import, quote: Offchain workers are spawned during each block import. However, they aren't executed during initial blockchain ...
Ronin's user avatar
  • 189
1 vote
1 answer
67 views

Off-chain worker. Error submitting a transaction to the pool: InvalidTransaction::ExhaustsResources [duplicate]

Error submitting a transaction to the pool: Transaction pool error: Invalid transaction validity: InvalidTransaction::ExhaustsResources It works fine in standalone but in parachain it fails. Off chain ...
rust.dev's user avatar
  • 519
1 vote
1 answer
39 views

What is Offchain Call in TransactionSource?

What is an Off-Chain Call in this scenario? for instance an Off-Chain Worker, or an Off-Chain Call source: https://github.com/paritytech/substrate/blob/master/primitives/runtime/src/...
Stefan Muto's user avatar
1 vote
1 answer
103 views

How to get the Peer count in an Off Chain Worker?

I have an Off Chain Worker that validates some data in IPFS and then calls a function on chain to set the status to valid or invalid. That's all working fine. However, I do not need all nodes to ...
jpataylor's user avatar
  • 321
1 vote
0 answers
30 views

How can we monetize heavy computation using substrate blockchain?

Suppose a reputation system is built, where bad nodes (open source docker instances running computations such as a search engine) are penalized, and good nodes are incentivized. What is the secure way ...
Amiya Behera's user avatar
1 vote
1 answer
43 views

Set Off-chain worker with AccountId20

The examples in substrate use the sr25519 AccountId and Multisignature for creating offchain workers with signed transactions. Is there a way to use AccountId20 and EthereumSignature for a node using ...
Discardo's user avatar
  • 436
1 vote
0 answers
34 views

How to create web socket server through off chain worker?

I need to establish a web socket connection through off chain worker. I asked here How to establish web socket connection in offchain_worker but didn't get any response. Is there any way/example to ...
Boleng's user avatar
  • 523
1 vote
1 answer
66 views

Iterating on a storage from Offchain Worker Concerns

I have a StorageMap named PublicKeyToMsaId which has around 300K inserted items and I want to iterate on all of those keys-values in offchain-worker to create a reverse map in offchain storage. To ...
Aramik M's user avatar
  • 139