Threads
January 17th, 2022
We have currently 2 threads for the above date.
🛠│ dev-support
status - Resolved
Pythonic --> I’m trying to make a nexxtjs app with near and I don’t really understand how to do SSR properly so that the app is interactive if the client has JS installed but also visible if they don’t
Pythonic --> this is what I have originally but it’s causing problems
Pythonic --> ```js
export async function getStaticProps(context) {
// Props to update then pass on
let near;
let wallet;
// Client Side Rendering
if(typeof window !== “undefined”) {
const config = {
networkId: “testnet”,
keyStore: new keyStores.BrowserLocalStorageKeyStore(),
nodeUrl: “https://rpc.testnet.near.org”,
walletUrl: “https://wallet.testnet.near.org”,
helperUrl: “https://helper.testnet.near.org”,
explorerUrl: “https://explorer.testnet.near.org”,
};
// connect to NEAR
near = await connect(config);
// create wallet connection
wallet = new WalletConnection(near);
}
// Server Side Rendering
else {
const config = {
networkId: “testnet”,
nodeUrl: “https://rpc.testnet.near.org”,
};
// connect to NEAR
near = await connect(config);
wallet = undefined;
}
return {
props: {
near,
wallet,
}, // will be passed to the page component as props
}```
sohom --> btw which language are u using for smart contracts ?
Pythonic --> Rust?
Benji | NEAR --> what problems are u facing
Pythonic --> I want to have the NEAR javascript object whether or not the client has javascript enabled
Pythonic --> and since window is not available in ssr then I can’t create a near object that has a keyStore
🛠│ dev-support
status - Resolved
meatcurtains --> I have a question regarding the change method: why is it that I am able to add a message successfully, but I cannot attach a deposit amount without my function failing? I’m trying to reproduce some of the functionality that happens in the Guest Book example, but with a predetermined amount. One clue that tells me I’m missing something is that my app never forwards to the “Approve Transaction” screen that happens when you include a Donation Amount in the Guest Book example. Is there a step that I’m missing that allows the transaction to be signed or approved? Thanks so much!.
Benji | NEAR --> the reason the “approve transaction screen” appears is because you only have a function call access key. When u try and attach a deposit behind the scenes it’s like “oh shoot meatcurtains is trying to send some NEAR but only has a function call access key. We better go to the NEAR wallet site so that we can use a full access key to sign the transaction instead of their function call access key.” The NEAR wallet stores a full access key by default.
meatcurtains --> In the Guest Book example, it seems to be using a function access key to attach a deposit (or is a full access key some how in play here?). The Approve Transaction screen will appear if there is a deposit included in the method.
Benji | NEAR --> you cannot attach any NEAR using a function call access key. The problem you’re running into has to do with the access key running out of GAS
Benji | NEAR --> Wdym without your function failing? can u provide some more context and or some explorer links?
meatcurtains --> const ATTACHED_GAS = Big(1)
.times(10 ** 13)
.toFixed(); // NEAR --> 10k picoNEAR conversion
const ATTACHED_TOKENS = Big(0.26)
.times(10 ** 24)
.toFixed(); // NEAR --> yoctoNEAR conversion
contract.addMessage(
{ param1: "param-value" },
ATTACHED_GAS,
ATTACHED_TOKENS
);
meatcurtains --> Interesting update on the above: I figured out how to get this error message if I include a value above 0.25, but if I include a value below, it is empty: “Uncaught (in promise) Error: Access Key {account_id}:{public_key} does not have enough balance 0.2349304432410017 for transaction costing 0.2616008404923348368612”