substrate | Substrate : The platform for blockchain innovators | Blockchain library
kandi X-RAY | substrate Summary
kandi X-RAY | substrate Summary
Substrate is a next-generation framework for blockchain innovation .
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of substrate
substrate Key Features
substrate Examples and Code Snippets
Community Discussions
Trending Discussions on substrate
QUESTION
Let me know if I am on the right train of thought. I'm currently building a dapp that will be based on my own parachain, and I was wondering if by adding this pallet, it would be a way to allow users in my dapp to pay for membership.
Obviously I would have to have some extrinsic functions that are exposed through my dapp so that when they click and pay for membership, in the runtime, the membership pallet will add that user as a member. Can anyone confirm my thoughts on this?
This leads up to another question. Should I just create a smart contract to handle membership logic and deploy it on edgeware or some other parachain that already exists?
...ANSWER
Answered 2021-Dec-01 at 10:32obviously I would have to have some extrinsic functions that are exposed through my dapp so that when they click and pay for membership, in the runtime, the membership pallet will add that user as a member. Can anyone confirm my thoughts on this?
You can easily do this. pallet_membership
is just a container for members. As you will find in the pallet_membership::Config
, there are special origins that can be defined as those who have the authority to add or remove a member.
You need a new pallet that will handle the payment to join new members. Let's call this pallet_membership_payment
. Once pallet_membership_payment
has received the correct payment, it can call into pallet_membership::add_member
with whatever origin is required to satisfy it. Not that even if the origin requirement of add_member
is EnsureRoot
, pallet_membership_payment
can still practically get over it, if it is coded as such.
Should I just create a smart contract to handle membership logic and deploy it on edgeware or some other parachain that already exists.
The answer to this really depends on how much further logic does your application have next to handling this membership via fees. Also, it depends on the smart contract payment model (end user pays the fees) works for you If this is it, then it is pretty simple. You might have an easier time in a smart contract model. But, if you need certain optimisations, less fees, more performance etc. you will probably have to consider being your own (para)chain.
QUESTION
I have six stylized blocks, each with a like counter. Three div tags, of which the last two are working. When writing code in js, when you click on the like +-1 button, only the first block (card) is counted, while the other five remain unchanged. How can I make the code also work when you click like in other blocks, and display +- 1
...ANSWER
Answered 2022-Mar-14 at 17:17I am still missing some parts of your code. But I have understood your goal. For this reason, I have written a general example to make it clear to you what you need to pay attention to in order to get your code to work.
- Link your vote buttons to a click event.
- Determine if it is an up / down vote when it fires.
- Get the current count and recalculate the count. Important: parseInt()
- the value you pull from the DOM to calculate it.
- update the counting element
That's it!
QUESTION
What does ExtrinsicPayload
exactly do? I want to replicate the logic but something is missing.
ANSWER
Answered 2022-Jan-26 at 10:14You should pass {"withType": true}
to the sign method too.
QUESTION
FRAME2 storage get defined using following syntax:
...ANSWER
Answered 2022-Jan-17 at 09:30The formal documenation of StorageValue
can be found here https://paritytech.github.io/substrate/monthly-2021-09+1/frame_support/storage/types/struct.StorageValue.html
There you can see that the third generic QueryKind
is by default the type OptionQuery
, when you don't provide a specific type, then OptionQuery
is used.
In the method implementation of the type StorageValue
you can see it requires some bounds on the generics https://paritytech.github.io/substrate/monthly-2021-09+1/frame_support/storage/types/struct.StorageValue.html#impl
Especially it requires QueryKind: QueryKindTrait,
This means QueryKind must implement how the value is queried from storage.
There is currently 2 implementors: OptionQuery
and ValueQuery
: https://paritytech.github.io/substrate/monthly-2021-09+1/frame_support/storage/types/trait.QueryKindTrait.html#implementors
OptionQuery
implement the trait in a way that returns None when no value is found in the storage. ValueQuery
implement the trait in a way that returns some on empty value (configured by the generic OnEmpty
) when no value is found in the storage.
So you would use either ValueQuery
when you want to get some "default" value when you try to get some value from storage and there is no value, and OptionQuery
when you want to get None, when you try to get some value from storage and there is no value.
The consequences are visible in the signature of the method: the method get
will return either a value or an option: https://paritytech.github.io/substrate/monthly-2021-09+1/frame_support/storage/types/struct.StorageValue.html#method.get
QUESTION
This official docs is about custom pallet using an substrate's pallets.
https://docs.substrate.io/how-to-guides/v3/pallet-design/loose-coupling/#2-import-the-trait
I don't know exactly how to do this with 2 custom pallets?
...ANSWER
Answered 2022-Jan-05 at 17:42Here how I dit it:
For example: pallet BoTrading need to call get_suitable_lp on pallet BoLiquidity
pallets/BoLiquidity/src/lib.rs
QUESTION
I use node-template to practise the tutorials.
I have finished the start a private network and Permissioned Network. At the end, I can see Charlie joined the network as a full node. I want to go further, I try to make Charlie to be an authority node, I want to make Charlie's role the same as Alice's and Bob's.
I want to let a node automatically joined and became an validator to generate blocks and finalize blocks.
Previously, Charlie runs as :
...ANSWER
Answered 2022-Jan-03 at 15:22I got an answer substrate-validator-set. If you want to dynamically add validator on a PoA network, you need to add a session pallet, and let session to manage the auro key and grandpa key.
QUESTION
When we launch substrate-front-end-template, the first thing one sees is a bunch of dummy accounts with some Balance, and I was under the impression that these accounts were being fetched from Genesis storage of the running chain. However, when I went into chain_spec.rs
file and deleted all accounts, and even renamed some in the testnet_genesis function, I continue to see accounts, albeit with zero balance:
On the console, keyring.getAccounts()
returns these very accounts.
Here's what my ChainSpec looks like :
...ANSWER
Answered 2021-Dec-29 at 14:18Accounts are just public keys in the node template. This means you can check every possible public key and it will return zero. But that doesn't mean that there is any state associated to this account. (assuming you have configured an existential deposit above 0).
If you want to add accounts on genesis, just check out the testnet_genesis
. The endowed_accounts
(4th argument) is what you are searching for. These are the accounts that get some balance at genesis. All of this code is chain depended and you can change it as you like.
QUESTION
So every pallet type has more or less the same declaration : pub struct Pallet(_)
or pub struct Pallet(PhantomData)
where T: Config
. My question is what does T
stand for? Someone mentioned that T
represents the substrate runtime which led me to question, if a node has multiple running pallets, do they all share the same definition of T
?
ANSWER
Answered 2021-Dec-17 at 12:56T
is a generic type which represents the entire Runtime configuration for your chain.
Substrate is designed to be modular and configurable, and thus we allow every pallet to be completely configured for your needs.
A simple example of this is that we make no assumptions about what type you use for the block number for your chain. Throughout the code, the block number type is generic, and can be referenced by the T::Number
type.
At some point, that generic type needs to be concretely defined, which happens in the runtime configuration. This T
generic type is passed to all pallets in order to share what those concrete types actually are, and make everything work in the end.
Check out this repository for a helpful example of how you can transition to concrete types into generic types, and then it will be obvious how the T
syntax came to be:
QUESTION
In would like to plot density plots with certain values (for instance: median/mean/etc.). I also would like to display chosen values (for instance median) above the plotting area, so it would not interfere with the distributions itself. Also, in real life I have larger, more diverse dataframes (with much more categories) so I would like to spread the labels, so they would not interfere with each other (I want them to be readable and visually pleasing).
I found similar thread here: ggrepel labels outside (to the right) of ggplot area
And I tried to adopt this strategy (by fixing x coordinate instead of y and enlarging upper margin), but to no avail.
Here is the reprex dataframe:
...ANSWER
Answered 2021-Dec-15 at 17:41One option to achieve your desired result:
- Set
clip="off" in
coord_cartesian` - Make some room for the labels by increasing the bottom margin of the title
- Set
y=1.05
for the labels (the max of data range + the default expansion of the scale by .05) - Set
min.segment.length=0
- Increase the
ylim
for the labels - Nudge the position of the labels
Note: Getting your desired result you probably have to fiddle around with the values for the nudging, the ylim and the margin.
QUESTION
Besides my substrate network, I want to create a wallet app. When the user opens it, the account on the network should be created programmatically, I figured out how to generate mnemonic and the key pair, but how do i put my keypair on the blockchain? Can I just send tokens to a public key that never been seen on the network?
...ANSWER
Answered 2021-Dec-14 at 13:12Can I just send tokens to a public key that never been seen on the network?
Yes. If you use AccountId32
as account id, every account is just a 32 byte long public key.
Even when an account falls below existential deposit, the account "stays", only all associated data is reaped. Next time you send funds to this account, it will be usable again.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install substrate
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page