Questions tagged [offchain]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 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
  • 475
2 votes
1 answer
128 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
3 votes
1 answer
84 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
0 votes
0 answers
59 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
  • 475
2 votes
0 answers
39 views

Proof-of-Work Substrate Chain with Multiple Validators

I'm working on a Proof-of-Work (POW) substrate chain. Assuming we have four validators, all of which have enabled on-chain workers (OCW), is it accurate to state that each validator's OCW fetches data ...
Deepak Chaudhary's user avatar
3 votes
1 answer
80 views

How to use FixedU128?

I'm fetching floating value in offchain worker though lite-json. Json data: { "price": 0.5 } Here is the implementation to fetch the price: let price_str = match obj.clone() { ...
Deepak Chaudhary's user avatar
4 votes
1 answer
123 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
0 answers
20 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
1 vote
1 answer
67 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
3 votes
0 answers
93 views

sending an http request in unit tests?

I'm trying to arrange some unit tests for a local http server connectivity my node communicates with. While the node has no troubles while sending requests, I face difficulties trying to build basic ...
Yury Yukhananov's user avatar
3 votes
0 answers
22 views

Offchain Storage lock vs compare-set/mutate function

While using offchain workers when do we want to use a StorageLock and when would we want to use a mutate function on StorageValueRef since both of them are kind of lock on db.
Rusty Pythonic Script's user avatar
2 votes
1 answer
89 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
45 views

can't use BTreeMap with custom key struct for offchain Local Storage

I'm trying to use sp_std::collections::btree_map::BTreeMap for offchain worker Local Storage. While let foo = StorageValueRef::persistent(b"bar::foo"); foo.get::<BTreeMap<u32, u32>&...
Yury Yukhananov's user avatar
4 votes
2 answers
200 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
7 votes
2 answers
195 views

How to mint offchain NFT in pallet_nfts

I want to try out offchain minting feature in pallet_nfts. This extrinsic nfts.mintPreSigned(mintData, signature, signer) should be used to claim the NFT as a final step. Before that, mintData ...
Filk's user avatar
  • 115
0 votes
1 answer
57 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
  • 519
0 votes
0 answers
72 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
2 votes
1 answer
114 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
3 votes
1 answer
104 views

What is the best way to add additional libp2p protocols to Substrate client?

We want to reuse the clients libp2p instance for receiving threshold signature shares directly from our users, for key resharing/rotation as validators join/leave the active validator set, ...
Jake Hemmerle's user avatar
3 votes
3 answers
154 views

What is KeyTypeId, and how to use it?

When I made use of an offchain signed extrinsic to send a transaction to a chain, I copied a snippet from others, which is like this: use sp_core::crypto::KeyTypeId; pub const KEY_TYPE: KeyTypeId = ...
kugool's user avatar
  • 161
2 votes
0 answers
96 views

Using a substrate crate for a standard rust project

I just discovered substrate. I would like to use, as a dependency a substrate crate which uses sp_io and sp_runtime offchain feature. The naive code I wrote fails because of "Externalities" ...
Vinamo's user avatar
  • 21
2 votes
1 answer
90 views

How to generate key pair in pallet or on offchain work

I received a task which is generating key pair in pallet on chain logic. I know that I should import sp_core crate. I import it like this: "use sp_core::Pair;" This line was written at the ...
kugool's user avatar
  • 161
4 votes
2 answers
86 views

Offchain workers in parachain

On a parachain (Substrate polkadot-v0.9.20 branch), I am trying to trigger some offchain tasks using an offchain worker in my pallet, but the task is not triggered. I checked that the on_finalize hook ...
LaurentTrk's user avatar
14 votes
0 answers
88 views

Outbound network traffic linearly growing with offchain protocol and recommendations for handling traffic growth

Issue We are experiencing a behaviour on our standalone/parachain node where the Network Bps on our cloud provider linearly increases throughout the lifecycle of our protocol. The increase continues ...
Drew Stone's user avatar
  • 1,194
9 votes
1 answer
69 views

Is there any way to get all the key/value pairs together from sc_client_db::offchain::LocalStorage?

I can see we have the option to get the values by using their keys one by one using get(), but is there any way to get all the pairs together wrapped in an iterator so that we don't need to hit the ...
Pawan Bisht's user avatar
6 votes
2 answers
129 views

How to parse/match a specific frame_system event?

From the following function I can read the frame_system events: let events = frame_system::Pallet::<T>::read_events_no_consensus(); the above provides me the following example array: ...
Pablo Buitrago's user avatar
6 votes
1 answer
147 views

How to extract data from Offchain storage in client-side?

I'm trying to access data that I'm storing through the RPC off-chain endpoint. Is there any way to get the instance of off-chain storage in service.rs through which we can extract that has been ...
Pawan Bisht's user avatar
2 votes
1 answer
70 views

Off-chain DB indexing example

Where can I find Tomasz Drwięga Off-chain DB indexing example, implementing the following runtime function? fn on_finalize(_n: BlockNumberFor<T>){} TIA
Pablo Buitrago's user avatar
5 votes
2 answers
127 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
12 votes
2 answers
642 views

How to verify a signature in a Pallet?

I have a Pallet that should verify a signature for some input data and a specific public key. It looks like this: fn verify(_: OriginFor<T>, data: Vec<u8>, sig: ???, from: ???) Is this ...
Oliver Tale-Yazdi's user avatar