Skip to main content

Questions tagged [offchain-worker]

Oracle-like capabilities for Substrate chains.

Filter by
Sorted by
Tagged with
1 vote
0 answers
12 views

How to store files in offchain worker and its hash in blockchain?

Can offchain worker be used for storing large files. I want to eliminate third party ipfs gateways for storing files. I need a code example for uploading and storing files in offchain worker and its ...
Amiya Behera's user avatar
0 votes
0 answers
13 views

Substrate: function can be called only from offchain workers

i just made a pallet where there is a function callable from users, this function will save some input data inside a storageMap, then offchain worker take the input data, do some operations and should ...
Jacopo Mosconi's user avatar
0 votes
1 answer
21 views

Why Off-chain worker does not deduct DispatchError in Substrate?

I am trying Substrate official off-chain example. I am throwing a DispatchError in my extrinsic. #[pallet::call_index(0)] #[pallet::weight({0})] pub fn submit_price(origin: OriginFor&...
Boleng's user avatar
  • 568
0 votes
0 answers
18 views

Not able to submit multiple signed transactions through off-chain worker

I have to submit 2 signed extrinsics through off-chain worker. The code structure of my off-chain worker is like this: fn offchain_worker(block_number: BlockNumberFor<T>) { if !...
Boleng's user avatar
  • 568
0 votes
0 answers
25 views

Is there e2e testing framework/example for Substrate solo chain?

I am working on a live solo chain. I have to test a scenario where I want to hit HTTP API through off chain-worker. Unfortunately it's not possible to test in mock environment. We can take an example ...
Boleng's user avatar
  • 568
1 vote
0 answers
13 views

Encrypting data offchain / decrypting data with offchain worker

I want to create a StorageMap which looks like so: pub type EncryptedData<T: Config> = StorageMap<_, Blake2_128Concat, SomeId, SomeEncryptedValue, OptionQuery>; I plan to encrypt the data ...
WhisperingZebra's user avatar
4 votes
1 answer
54 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
1 vote
0 answers
34 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
37 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
  • 568
0 votes
1 answer
49 views

execute_block, initialize_block, apply_extrinsic, finalize_block, offchain_worker exists for struct `Executive` but its trait bound were not satisfied

I developed substrate parachain with custom pallets. Actually I wanna add OCW functionality to one of my pallets. After I updated runtime code and added CreateSignedTransaction implementation I tried ...
Artem Levchuk's user avatar
0 votes
0 answers
27 views

How to send HTTP POST request using Substrate Offchain worker

I am using Substrate official example to send HTTP POST request, which is mentioned here https://docs.substrate.io/reference/how-to-guides/offchain-workers/offchain-http-requests/#read-and-submit-the-...
Boleng's user avatar
  • 568
0 votes
1 answer
44 views

Substrate Offchain Worker - failed to fetch sample price

I am trying to use Substrate Offchain Worker. I implemented as mentioned here https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/examples/offchain-worker. I am using same sample ...
Boleng's user avatar
  • 568
2 votes
1 answer
170 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
1 vote
1 answer
94 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
  • 568
2 votes
1 answer
45 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
0 votes
0 answers
17 views

Troubleshooting Sequential Unsigned Transaction Processing with 200 Validators

we're attempting to send unsigned transactions from an offchain worker using the validation code snippet provided: ValidTransaction::with_tag_prefix("thea") .and_provides(...
ZKT's user avatar
  • 113
1 vote
1 answer
51 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
3 votes
0 answers
27 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
0 answers
90 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
3 votes
1 answer
92 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
  • 161
0 votes
0 answers
66 views

How to execute smart contract from offchain-worker?

Would it be possible to execute smart contract call from an offchain-worker, either using ink! or pallet-contracts? Can someone please help me to provide the solution? is there any example?
Boleng's user avatar
  • 568
1 vote
0 answers
35 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
  • 568
1 vote
1 answer
158 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
  • 568
4 votes
1 answer
134 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
1 vote
1 answer
70 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
  • 161
2 votes
1 answer
69 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
50 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
1 vote
0 answers
32 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
72 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
34 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
119 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
86 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
1 answer
18 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
2 votes
1 answer
53 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
41 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
55 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
52 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
97 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
87 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
87 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
4 votes
2 answers
213 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
38 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
25 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
61 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
77 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
  • 539
0 votes
1 answer
62 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
  • 539
1 vote
1 answer
60 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
75 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
155 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
163 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