Threads
January 16th, 2022
We have currently 10 threads for the above date.
đ â dev-support
status - Unresolved
lev_s --> Is there anything like a priority queue implementation for smart contracts?
lev_s --> I see TreeMap
but was wondering if it would be possible to get like the nth largest item, not just the max
đ â dev-support
status - Resolved
camchis --> is using random_seed()
okay for 50/50 probability or not yet?
Benji | NEAR --> so it is random, but technically is not completely uninfluenced by validators as they can choose not to produce a block to affect the result of this, but in most cases I donât think this is a concern. You might want to introduce more entropy somehow to make this more difficult to game if imperative that there is no influence on this randomness and there would be an incentive for validators to avoid publishing blocks
camchis --> thank you, will this change in the future?
camchis --> so any sort of casino game is not really feasible atm as if ppl running validators are playing and they lose they can just not produce those blocks and only produce blocks if the result is in their favour?
Obedear --> Thats why you donât put the casino game in the contract dude
Obedear --> You canât put randomness into SOL contracts and they still make casinos
camchis --> seems like there is a gh issue to improve the randomness https://github.com/near/nearcore/issues/779
camchis --> but doesnât seem to be very active
Benji | NEAR --> Most probably not
Benji | NEAR --> might be a stale issue
đ â dev-support
status - Resolved
vans163 --> is there a way to log inside AssemblyScript unit tests to console, also is there a way to run the tests much faster? even a simple helloworld seems to take 5-10 seconds
vans163 --> So your kind of in this 1 hour lesson ask a bunch of questions and learn some new API, then you work on your own until the next day and gather questions for the next days lesson or stuck points your on. On the final day you need to present a github repo of a project you implemented using the knowledge over the 5 days
vans163 --> It could be a simple hello-world it does not matter, as long as you learn
Obedear --> Yo anyone know why my config aint working
Obedear --> also what keystore method do I want to use when allowing users to connect to the dApp with their wallets?
vans163 --> dont set the keystore like that for website
vans163 --> its automatically set
vans163 --> keystore is set here
vans163 --> ```
window.provider = new nearlib.providers.JsonRpcProvider(nearConfig.nodeUrl);
// Initializing connection to the NEAR DevNet.
window.near = await nearlib.connect({
deps: { keyStore: new nearlib.keyStores.BrowserLocalStorageKeyStore() },
âŠnearConfig });
vans163 --> on the connect step
Obedear --> where are the docs for that?
Obedear --> and what is the window property?
vans163 --> im not sure its all ove the place i dont read the docs i just follow a project that works
vans163 --> cuz the docs are kinda messy and google returns stale docs often
Obedear --> do u have a link to a project?
vans163 --> <@!Obedear> here is implementation i wrote for hackathon last metabuild https://github.com/xenomorphtech/lkr_public/blob/main/website/near.js
vans163 --> simple NFT marketplace
Obedear --> thanks man
Obedear --> var nearlib = window.nearApi; whats up with this, I have no idea what the windows. is lol
vans163 --> you can use `globalThis.nearApi` thats more generic. BUT nearapi wont work outside a browser environment anyways so it doesnt matter
vans163 --> or maybe it can now not sure
vans163 --> window == the browser context https://developer.mozilla.org/en-US/docs/Web/API/Window
Obedear --> I think mine isnt working because im using typescript react not js
Obedear --> would that make a difference?
vans163 --> Yea im not sure if typescript has a `window.` use `globalThis.` or whatever typescript recommends for state storage
vans163 --> you can remove that line even
vans163 --> and just replace it with a variable
Obedear --> yeah thats what I want trying, still having some issues with typescript
vans163 --> yea iunno about TS here, it always pisses me off lol because its not end to end static typed like Elm. so whats the point of jumping thru all the hoops if you can still get runtime crashes
Obedear --> seems to be having issues with the safe-buffer package
vans163 --> sorry no idea
vans163 --> i never ran near-api-js inside a typescript env
Obedear --> ima just make a js environment most likely easier
Obedear --> Damn still having this issue with js as well
vans163 --> how do you log to stdout in unit tests for AS?
Benji | NEAR --> i'm not too sure i don't use AS - cc <@!Dorian | NEAR>
đ â dev-support
status - Resolved
Efizzz --> Hi all, would like some insight if somebody could please help:
Letâs say I create a contract that saves data to a PersistentUnorderedMap.
PersistentUnorderedMap saves data to the blockchain, so I am guessing that this data will get included with some block.
Is that assumption correct? If it is, is this data readable in the block?
Letâs say account1 is calling this contract to save the data. If the data is saved to a block, is the accountId that called the contract connected to this data in any way?
Benji | NEAR --> The chain has blocks which contain the transactions. The transactions include the arguments passed in.
Benji | NEAR --> if the data isnât being passed in via arguments, the only way to read the state would be if u had a view function on your contract
đ â dev-support
status - Resolved
secretluver(Razor) --> Running into an issue with near-api-js
. I have my keypairs saved in my local filesystem and I can deploy normally for my root level domain (test.near
) but I canât deploy for any of its subdomains (hello.test.near
). I have both keys saved to my filesystem. Attaching screenshots.
secretluver(Razor) -->
spiritbro1 --> hello guys i want to deploy validator node on localnet using kortosis i still doesnt understand what should i write in the input especially this line "staking_pool_id":"<POOL_ID>", "owner_id":"<OWNER_ID>", "stake_public_key":"<VALIDATOR_KEY>"
what should i write on POOL_ID, OWNER_ID, and VALIDATOR_KEY?
Benji | NEAR --> so you have test.near
which can deploy a contract correctly and then ur making the account hello.test.near
and ur saying that that account canât deploy a contract?
secretluver(Razor) --> I was creating hello.test.near
and deploying a contract to it in 2 separate transactions.
This problem is resolved, I found out what I was wanting to do can be done with account.createAndDeployContract(...)
.
Benji | NEAR --> awesome glad u figured itout
secretluver(Razor) --> Just curious, but what would I call in near-api-js
to deploy to hello.test.near
after that account has already been created?
đ â dev-support
status - Resolved
totalbanjo --> hi
totalbanjo --> reading the AssemblyScript intro here: https://docs.near.org/docs/develop/contracts/as/intro
totalbanjo --> it says âAssemblyScript smart contract development is for non financial use cases.â
totalbanjo --> can you please elaborate on this? isnât everything on the bc essentially financial in nature?
totalbanjo --> and why not use assembly script for financial use cases? whatâs the limitation? is there a security issue with it?
Evan Feenstra --> Assemblyscript has more dependencies than rust⊠if there were millions of $ on the line, that would be an incentive for someone to try to corrupt assemblyscript itself to steal funds. Highly unlikely⊠but that is one possible reason to choose rust for financial apps
secretluver(Razor) --> ^Didnât think about that. Rust also has strong memory and runtime performance.
totalbanjo --> hmm surely thatâs not why this comment is there though?
totalbanjo --> I just want to understand the root cause for Near saying, âdonât use Assembly Script for financial use casesâ. that seems to invalidate their entire assembly script sdk, why would you use it for anything if itâs not safe to use
totalbanjo --> I understand the benefits of Rust, and drawbacks of assembly script. if it had said, hey âif you use assembly script, itâll take more storage, itâll be slower, so consider your use caseâ, but it doesnât say that, it says donât use it
totalbanjo --> why?
Benji | NEAR --> itâs not as mature of a language as rust and so we recommend using Rust for any complex financial use cases.
totalbanjo --> this feels like an unsatisfactory answer tbh. is using the Assembly Script sdk secure?
đ â dev-support
status - Resolved
Obedear --> Anyone know how to solve this buffer issue, I have tried re installing the package many times
Benji | NEAR --> local storage should work fine
Benji | NEAR --> https://stackoverflow.com/questions/70296914/near-protocol-referenceerror-buffer-is-not-defined
Obedear --> dw I fixed it
Obedear --> Here are all my package versions
Obedear --> this didnât solve my issue, is there a step im missing after adding the line to ur file
Benji | NEAR --> what was the problem?
Obedear --> I had to put
import * as buffer from âbufferâ;
(window as any).Buffer = buffer.Buffer;
in my app.tsx file and now it works
đ â dev-support
status - Resolved
Obedear --> I am getting this error when attempting to use requestSignIn
Vitcos --> I had the same problem and found two solutions. You can either build your project with Parcel or use this solution https://github.com/agoncal/swagger-ui-angular6/issues/2#issuecomment-435307286
Vitcos --> Hi, Iâm making contract with Rust and I stumbled upon the problem. I have a LookupMap
that stores Vector<bool>
. I want to change one boolean value inside that Vector
. The problem is that LookupMap
doesnât provide get_mut
method which would allow me to mutate that vector. From documentation I read that get
returns just a value not a reference. Is there any option the change that one value without initializing the whole vector? Thanks for any help đ
đ â dev-support
status - Resolved
buddhaha --> Hi, I want to get hold of the contractâs owner_id so that payments can be made to it on mint. However, I get this error: move occurs because `self.owner_id` has type `near_sdk::AccountId`, which does not implement the `Copy` trait
This is the line Iâm trying to run: Promise::new(self.owner_id).transfer(MINT_PRICE);
Any suggestions on what I should do?
Benji | NEAR --> quick solution would just be to add a .clone()
to the other place youâre using owner_id
buddhaha --> thanks đ
buddhaha --> While youâre here, how much yoctoNEAR is one NEAR?
buddhaha --> Not sure if function does not work or if I put in way too little of an amount đ
Benji | NEAR --> 10^24
buddhaha --> any built in method for converting that?
Benji | NEAR --> not in rust SDK afaik
buddhaha --> okay, thanks
buddhaha --> Method is working now đ Thanks alot
đ â dev-support
status - Unresolved
billy345 --> Hi all, I have a question about using prepaid gas in applications as per https://docs.near.org/docs/concepts/gas#what-about-prepaid-gas.
It is possible to create access keys for the deploed SC entirely from the browser API with near-api-js, without having intermediate server to create access keys?
Benji | NEAR --> you can create key pairs locally but you need to add them to the account which you can do with NAJ using the account.addKey
method