Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using env variable for setting up NEAR Social contract address #44

Open
jaswinder6991 opened this issue Jul 25, 2023 · 4 comments
Open

Comments

@jaswinder6991
Copy link
Contributor

At src/social_db.rs, we define social db contract's address as hardcoded:

use near_sdk::ext_contract;
use near_sdk::serde_json::Value;

pub const SOCIAL_DB: &str = "social.near";

#[ext_contract(ext_social_db)]
pub trait SocialDB {
    fn set(&mut self, data: Value);
}

While working on testnet and sandboxes, this have been a problem. I think we can use env variables to load the contract address.

@jaswinder6991
Copy link
Contributor Author

I want to work on this.

@frol
Copy link
Collaborator

frol commented Jul 28, 2023

Indeed, it makes sense to be able to customize it for different networks.

There is no “env variables” concept in near contracts. You will need to store the value in the contract state and initialize on construction (new method)

@jaswinder6991
Copy link
Contributor Author

Okay great. I will start working on including it in the contract state. I am assuming it would need migrations to be written too? I can take a crack at it as well.

@frol
Copy link
Collaborator

frol commented Jul 29, 2023

@jaswinder6991 I did not put too much thinking into it, but if you go the proposed route, you will need to implement the migration, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants