Threads
January 4th, 2022
We have currently 10 threads for the above date.
š ā dev-support
status - Resolved
confusion summary: How to get NFTs listed for sale in a marketplace with REST
resolution summary: 1. Build a REST API to keep track of all sales in the market place. 2. NFTs to populate a DB at the end of each day 3. View calls.
totalbanjo --> hello, Iām working on a Near marketplace. This is surely a rather silly question, but Iāve looked through the vast dev documentation/examples and I canāt see any examples of simply -> get NFTs listed for sale from API, at least as a starting point. any help please?
Benji | NEAR --> Do you mean through view calls or a REST API?
totalbanjo --> Rest API
Benji | NEAR --> youāre going to need to keep track of that information yourself and create APIs. The way my team does it is we run an indexer to listen for transactions incoming on our contracts and then do a POST to our API to keep track that thereās a sale and then we can just do a GET whenever if we wanna see all the NFTs for sale.
totalbanjo --> Hmm damn, sounds way more complicated than it should be.
So what if I want to list all NFTs on my marketplace, not just those minted through my contract?
Benji | NEAR --> you can do that through view calls if youād like but if you want it in a REST API, youāre gonna have to do some infrastructure stuff. You can also loop through your NFTs to populate a DB at the end of each day but that wonāt always give the most up to date information throughout the day
totalbanjo --> Looks like I need view calls then
totalbanjo --> Is there an example of doing that using view calls?
Benji | NEAR --> https://github.com/near-examples/nft-tutorial/blob/main/market-contract/src/sale_views.rs
š ā dev-support
status - Resolved
Dav --> Hello guys,
iām working for guildnet, iām updating Guildnet Wallet based on latest Near-Wallet.
We have :
1 Server for Near-Wallet
1 Server for Near-contract-helper
Iām still facing issue with Recovery
Step to reproduce:
Create a wallet on https://wallet.openshards.io/ with passphrase
Open a new window on another browser to recover the wallet on https://wallet.openshards.io/recover-seed-phrase
Enter the previous passphrase
Uncaught (in promise) Error: Cannot find matching public key
at Wallet.recoverAccountSecretKey (wallet.js:977)
at async Wallet.recoverAccountSeedPhrase (wallet.js:943)
at async _index.Mixpanel.withTracking.setState.recoveringAccount (RecoverAccountSeedPhrase.js:87)
at async Object.withTracking (index.js:16)
at async RecoverAccountSeedPhrase.handleSubmit (RecoverAccountSeedPhrase.js:84)
(I added some debug log)
secretKey:ed25519:53UVQqDDRGfuGq4iuzCRWNpiZPb24fmYS1hCB5XGFdQVjLGaSuP84hnUy83SDTeNKRurgRZP5FEJ9mTPiirgTfoP
publicKey: ed25519:2gfTh4pWywiutHU4eCAmQUVAHbXxpftDzeQcUMFi73Mj
tempKeyStore: InMemoryKeyStore
implicitAccountId: 1904d35754181ad12f561d62f6984c01f6f8fdc3bee68bcbea606c8e2522cfba
DB :
New account in "Accounts"
New line in āRecoveryMethodsā
no new line in āAccountByPublicKeysā and āEmailDomainBlacklistā
So information how to find the problem ?
Dav --> Can Dev check my question : https://discord.com/channels/490367152054992913/542945453533036544/927853928656285708
?
Thank you
Benji | NEAR --> Iāve never worked with Guildnet so I wonāt be much help, sorry š¦
Dav --> guildnet is just another network like testnet š
Dav --> i suppose i need configure something in helper to get the correct information but need Wallet/ Contract Helper expert
Dav --> <@!Daryl | NEAR> is the boss but very busy right now
Benji | NEAR --> I unfortunately wonāt be of much help š¦ Iāve gotta hop to another meeting very soon so perhaps <@!Dorian | NEAR> can take the lead on this?
Benji | NEAR --> Yea Daryl is a really busy person š¦
Dav --> Need to find why contract helper dont return data
Dorian | NEAR --> Hey <@!Dav> What is it exactly you need assistance with?
Dorian | NEAR --> Itās definitely weirdā¦
Dav --> I use default configuration.
Wallet Is on a server and helper on another.
Dorian | NEAR --> Ohh I see
Dav --> Staking work, creation account too. But recovery and get validators who have staking dont work.
I will check again tomorrow but there Is no Doc on itā¦
Dorian | NEAR --> just out of curiosity what resources were you using to create your own wallet? Maybe I can take a look at your reference material?
Dav --> I used near-wallet from git
Dorian | NEAR --> perhaps we can hop into the office hours room and talk through this?
Dav --> maybe tomorrow, more than midnight here ^^
Dorian | NEAR --> Ah ok haha
Dorian | NEAR --> Quick Q tho, why are you using an inMemoryKeyStore vs local storage?
Dorian | NEAR --> I think if Iām correct the wallet uses local storage
š ā dev-support
status - Resolved
Indispensable --> Hello, I am trying to stake my locked tokens and when I choose a validator and stake, I get the following error: Smart contract panicked: panicked at āThe balance that can be deposited to the staking pool is lower than the extra amountā. Not sure what this means. Can someone please throw some light on this issue? I tried multiple validators but I get the same error.
Benji | NEAR --> You probably donāt have enough balance. See this thread here. https://discord.com/channels/490367152054992913/490367152054992917/761507094092185630
š ā dev-support
status - Resolved
silencebringer69 --> Hi thanks for the solution, we were able to create sub-accounts by using your solution. Since we need the private key in order to generate a keystore. Is there any way to get the private key of sub-account? We can get the credentials of a sub-account if it is created by using the near-cli but, I am looking for a NEAR-JS-API functionality.
Benji | NEAR --> Hmm thatās a good question. Iāll look into it
Benji | NEAR --> Haha I had a major brain fart. You already have the keyPair!
Benji | NEAR --> ```javascript
const keyStore = new keyStores.InMemoryKeyStore();
const ACCOUNT_ID = ābenjiman.testnetā; // NEAR account tied to the keyPair
const NETWORK_ID = ātestnetā;
keyStore.setKey(NETWORK_ID, ACCOUNT_ID, KeyPair.fromString(āYOUR_PRIVATE_KEYā));
const config = {
networkId: "testnet",
keyStore, // optional if not signing transactions
nodeUrl: "https://rpc.testnet.near.org",
walletUrl: "https://wallet.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://explorer.testnet.near.org",
};
const near = await connect(config);
let keyPair = await KeyPair.fromRandom('ed25519');
let pubKey = keyPair.getPublicKey();
console.log('pubKey: ', pubKey);
const account = await near.account("benjiman.testnet");
const foo = await account.createAccount(
"benjiman-in-memory-testing3.benjiman.testnet", // new account name
pubKey, // public key for new account
parseNearAmount("1") // initial balance for new account in yoctoNEAR
);
Benji | NEAR --> You create a keyPair using `await KeyPair.fromRandom`
Benji | NEAR --> and then use the public key of that keypair for your newly created account
Benji | NEAR --> so you have the keypair stored in the `keyPair` variable
silencebringer69 --> How can I deploy a contract from this newly created account? Don't I need a keystore to deploy a contract? What the config will look like for newly created subaccount? I am sorry I am not being able to put the puzzle pieces together.
const near = await connect(config);
const account = await near.account("example-account.testnet");
const response = await account.deployContract(fs.readFileSync('./wasm_files/status_message.wasm'));
console.log(response);
Dorian | NEAR --> hello!
Dorian | NEAR --> You would need a full access key pair to deploy a smart contract to that account if that make sense.
Dorian | NEAR --> and actually i just made an a similar example for this scenario lol
Dorian | NEAR --> https://github.com/near-examples/contract-that-deploys-contracts-rs
silencebringer69 --> You are a life savior bro! Thanks very much, will give it a try š
Dorian | NEAR --> let me know what you think! haha any feedback would be much appreciated
silencebringer69 --> Sure thing!
Benji | NEAR --> <@!silencebringer69> I wrote up the code for you.
Benji | NEAR --> ```javascript
const keyStore = new keyStores.InMemoryKeyStore();
const ACCOUNT_ID = "benjiman.testnet"; // NEAR account tied to the keyPair
const NETWORK_ID = "testnet";
keyStore.setKey(NETWORK_ID, ACCOUNT_ID, KeyPair.fromString("YOUR_PRIVATE_KEY"));
const config = {
networkId: "testnet",
keyStore, // optional if not signing transactions
nodeUrl: "https://rpc.testnet.near.org",
walletUrl: "https://wallet.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://explorer.testnet.near.org",
};
const near = await connect(config);
let keyPair = await KeyPair.fromRandom('ed25519');
let pubKey = keyPair.getPublicKey();
const subAccountId = "benjiman-in-memory-testing-contract.benjiman.testnet";
const account = await near.account("benjiman.testnet");
await account.createAccount(
subAccountId, // new account name
pubKey, // public key for new account
parseNearAmount("1") // initial balance for new account in yoctoNEAR
);
keyStore.setKey(NETWORK_ID, subAccountId, keyPair);
console.log('keyStore: ', keyStore)
const subAccount = await near.account(subAccountId);
const response = await subAccount.deployContract("./main.wasm");
console.log('response: ', response)
Benji | NEAR --> This will create a sub account and then deploy a contract to it
Benji | NEAR --> See here: https://explorer.testnet.near.org/accounts/benjiman-in-memory-testing-contract.benjiman.testnet
Benji | NEAR -->
Benji | NEAR --> just set the key in the keyStore using the keyPair object
silencebringer69 --> That worked, thanks! You are awesome š
š ā dev-support
status - Resolved
confusion summary: Would the Dev Rel team hold office hours today?
resolution summary: Yes
AnkushSantra --> <@!Benji | NEAR> Good Evening, Sir. Can I expect the Dev Rel team to be online today in the office hours?
Benji | NEAR --> Indeed we shall š - 2pm ET
AnkushSantra --> Thank You for the quick reply. I would surely join today.
š ā dev-support
status - Unresolved
confusion summary: How to RPC query to get lockup accounts for account_ids?
demipop --> hey sorry for simple Qās. if thereās a channel for folks working on indexer/queries happy to chat in there. i usually assume iām missing something haha:
has anyone figured out a good way to rpc query to get lockup accounts for account_ids?
š ā dev-support
status - Unresolved
confusion summary: Speed of view methods in a contract
vmod --> how fast are view methods in a single contract usually
š ā dev-support
status - Resolved
imz13 --> hi⦠did i lose my funds if i sent NEAR to the token address i was provided by near wallet instead of to my user ID?
Dorian | NEAR --> Like the one you used to initiate your account?
Benji | NEAR --> <@!imz13> <@!BT1> can you ask in <#š¤ ā community-support>
imz13 --> Thereās a recovery method
imz13 --> Thank goodness
š ā dev-support
status - Unresolved
confusion summary: What is the RUST json_types -Base64VecU8 equivalent for AssemblyScript?
Aaron | Vital Point AI --> Anyone know what the equivalent of the RUST json_types -Base64VecU8 is for AssemblyScript?
š ā dev-support
status - Resolved
Hatchet --> Anyone know why the NFT standard implementation only refunds amounts greater than 1 yoctoNEAR? https://github.com/near/near-sdk-rs/blob/master/near-contract-standards/src/non_fungible_token/utils.rs#L39
Benji | NEAR --> how are you gonna refund 0 yoctoNEAR? You canāt refund nothing
Benji | NEAR --> oh youāre asking if itās 1 yocto NEAR?
Hatchet --> But it wonāt refund 1 yoctoNEAR
Hatchet --> yes exactly
Benji | NEAR --> yea I mean thatās an edge case and thatās such an insanely small unfathomable number that it doesnāt matter
Benji | NEAR --> it could be greater than or equal to
Hatchet --> It just seems like a weird and unnecessary exception - why not just say if refund > 0
?
Benji | NEAR --> you could do that for sure
Hatchet --> Ok, just confirming itās not there for some other reason. Thanks!
Benji | NEAR --> haha yea no problem !