Questions tagged [offchain-worker]

Oracle-like capabilities for Substrate chains.

Filter by
Sorted by
Tagged with
2 votes
1 answer
52 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
31 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
  • 51
1 vote
0 answers
11 views

offchain worker choose key to sign and send

I have multiple keys in my node storage with offchain worker running, there are currently 2 ways to sign and send transactions, it is done either for all of the keys stored locally, or 1 unspecified ...
cocokick's user avatar
  • 165
0 votes
1 answer
53 views

Is runtime upgrade needed when changing offchain worker?

Suppose I have a blockchain that has been running for some time, and at a certain point, I need to update the offchain worker code. What is the recommended approach for updating the blockchain: ...
subuser's user avatar
2 votes
0 answers
30 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
1 vote
0 answers
54 views

Is 'Ran out of free Wasm instances' a bad symptom?

I develop a custom chain based on Substrate. The chain business logic involves stateful sessions where the state is managed through Http and unsigned transactions submitted via Offchain workers. Until ...
Yury Yukhananov's user avatar
1 vote
1 answer
40 views

How to use Offchain Workers to create HTTP POST requests with JSON-RPC body?

Too my knowledge there are no guides on how to write HTTP POST requests to a JSON-RPC API with http utilities that are available to Substrate offchain workers. What I understand currently is that the ...
zimbabwe_slim's user avatar
0 votes
0 answers
14 views

Unit testing an extrinsic submitted by an Offchain Worker?

As far as I could understand so far there is no a "normal" way to test extrinsics submitted by an Offchain Worker, rather a substitute transaction pool is involved. However it is possible to ...
Yury Yukhananov's user avatar
0 votes
1 answer
15 views

URI creation best practice

What is the best practice to create a URI in an off-chain worker hook? The String and format! usage is discouraged. But what is the most convenient way to create a URI from given parts like hostname, ...
khassanov's user avatar
  • 105
0 votes
0 answers
45 views

Using http calls outside of offchain worker context

Is it possible make http requests outside of an offchain worker context. It seems like the only thing that is preventing http calls is simply that OffchainWorkerExt is not registered in the runtime. I'...
fastfist's user avatar
2 votes
1 answer
40 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
1 vote
0 answers
30 views

Fetching offchain storage value returns different value than the value fetched using localStorageGet function

I need to get the rpc_url value set initially from the explorer. The localStorageGet rpc function returns the correct value of the rpc_url. This returns https://eth-mainnet.g.alchemy.com/v2/MY_API_KEY ...
strider's user avatar
  • 11
4 votes
1 answer
47 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
44 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
2 votes
1 answer
56 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
67 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
0 answers
77 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
  • 111
4 votes
2 answers
155 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
2 votes
1 answer
31 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
1 vote
0 answers
20 views

How to connect with phala contract for creation of anonymous accounts using phala network?

I want to create anonymous account using phala network. Here is my logic. You need to sign with your kyc account using the password as message and verify that the account is yours inside phala ...
Amiya Behera's user avatar
1 vote
1 answer
48 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
  • 155
1 vote
1 answer
52 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
  • 509
0 votes
1 answer
44 views

How to enable off-chain workers for parachain via command line?

There is no any logs and off-chain workers does not work by default. How to specify to enable workers for parachain via command?
rust.dev's user avatar
  • 509
1 vote
1 answer
44 views

Iterate storage maps inside an offchain worker

I need to iterate over the following double map inside an offchain worker: How can I access this map outside the pallet assets? Can I use an RPC method to get all the values for that double map ...
Mateo Baldassarre's user avatar
0 votes
0 answers
65 views

offchain indexing for large files

I'm new to the project and currently working on a pallet, which is supposed to deal with large files offchain. Pallet, offchain indexing and the offchain worker are all working fine, still I get "...
langi667's user avatar
0 votes
1 answer
102 views

Is there any way to interact between ink smart contract and off-chain worker?

I know that we can interact between smart contract and runtime (and vice versa) but I can not find a way that I can fetch data from API (in off-chain worker pallet) and pass those data to the smart ...
Hoang Viet Nguyen's user avatar
4 votes
1 answer
121 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
0 votes
1 answer
79 views

Implementing an Identity Management pallet, would be more efficient in a Relay or Parachain?

I'm implementing an Identity Management pallet for an administrative ecosystem. Suppose that using the same architecture as Polkadot. Questions It would be more secure, efficient and scalable to have ...
Alexandre Ribeiro's user avatar
2 votes
1 answer
113 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
1 vote
1 answer
42 views

how does work offchain in substrate ( pokadot ) [closed]

I Wanna know about off-chain in the substrate ( Polkadot ) how does work? How is it mine from the onchain ( main chain in Polkadot )? maybe somebody wants to hack the off-chain and they do it a ...
Kianoush Dortaj's user avatar
1 vote
0 answers
45 views

Enabling Offchain workers in a parachain

I know the way to enable ocw in a solo chain is to edit the service.rs as per the documentation and it works perfectly. I have tried making equivalent changes to the service.rs in my parachain but ...
rh00's user avatar
  • 33
2 votes
1 answer
78 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
0 votes
1 answer
131 views

How to get data to off-chain worker from runtime?

Is any option to get data to off-chain workers from runtime? For example, I have used runtime to store something. How can I access this data from off-chain woker without using HTTP calls?
P.E's user avatar
  • 171
0 votes
0 answers
29 views

Is there a way to create a peer to peer network on top of substrate?

Most of substrate tutorials are based on on-chain logic so there's not much information on this topic. Is there a way to use Substrate's in-built p2p network for other purposes such as constant ...
Kofi's user avatar
  • 141
1 vote
0 answers
88 views

using any account for offchain worker signed transaction

I'm trying to implement the following sequence: Alice calls extrinsicA extrinsicA calls off-chain worker off-chain worker invokes an external service off-chain worker uses Alice for a signed ...
digital illusion's user avatar
2 votes
1 answer
108 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
0 votes
3 answers
191 views

Enabling off-chain workers for substrate-node-template

I'm trying to test offchain workers in my local substrate node. It seems that by default the ocw is not enabled? I've only been able to see logs from ocw's when running the node with the --dev option (...
random-bacon's user avatar
1 vote
1 answer
38 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
2 votes
1 answer
53 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
  • 161
5 votes
2 answers
146 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
1 vote
2 answers
108 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 am 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 ...
kugool's user avatar
  • 161
0 votes
1 answer
57 views

How to use "A secure, local entropy source for random number generation" in offchain worker?

The official website tells us there is " A secure, local entropy source for random number generation" . I think it means that I can make use of this feature to generate random number or even ...
kugool's user avatar
  • 161
2 votes
1 answer
99 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
0 votes
1 answer
101 views

app_crypto!(sr25519, KEY_TYPE): cannot find trait `TryFrom` in this scope

I am building an ocw demo, the code is from https://github.com/paritytech/substrate/blob/master/frame/examples/offchain-worker/src/lib.rs, when using polkadot-v0.9.25 version, it appears got this ...
Bart Yang's user avatar
2 votes
1 answer
116 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
3 votes
1 answer
71 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
0 votes
1 answer
76 views

How to get on-chain data on pallet?

I want to get some 'trustful' on-chain data on the pallet, for example, get transaction data by transaction hash. I found Offchain Workers might do that job but is it really trustful because the API ...
Stefan Muto's user avatar
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
2 votes
2 answers
148 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
1 vote
1 answer
94 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