How to use the stellar-sdk.Network function in stellar-sdk

To help you get started, we’ve selected a few stellar-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BitGo / BitGoJS / modules / core / src / v2 / coins / stellarToken.ts View on Github external
constructor(bitgo: BitGo, tokenConfig: StellarTokenConfig) {
    super(bitgo);
    this.tokenConfig = tokenConfig;
    const network = this.tokenConfig.network === 'Testnet' ? stellar.Networks.TESTNET : stellar.Networks.PUBLIC;
    stellar.Network.use(new stellar.Network(network));

    const [tokenCoin, token] = _.split(this.tokenConfig.type, Xlm.coinTokenPatternSeparator);
    if (tokenCoin !== tokenConfig.coin) {
      throw new BitGoJsError(`invalid coin found in token: ${this.tokenConfig.type}`);
    }
    if (!token || !token.match(StellarToken.tokenPattern)) {
      throw new BitGoJsError(`invalid token: ${this.tokenConfig.type}`);
    }
    [this._code, this._issuer] = _.split(token, '-');
  }
github future-tense / stargazer / app / core / services / horizon.js View on Github external
function getHash(passphrase) {
	return new StellarSdk.Network(passphrase)
	.networkId()
	.toString('hex')
	.slice(0, 8);
}
github rate-engineering / rate3-monorepo / packages / stellar-contracts / r3-stellar-js / r3-stellar.js View on Github external
export async function R3Stellar(network, serverURI) {

    const passPhrase = Stellar.Networks[process.env.STELLAR_NETWORK];
    Stellar.Network.use(new Stellar.Network(passPhrase));
    
    const stellar = new Stellar.Server(serverURI);

    const assetContracts = AssetContracts(stellar, Stellar);
    const hashedTimeLockContracts = HashedTimelockContracts(stellar, Stellar);    

    return {
        stellar,
        Stellar,
        assetContracts,
        hashedTimeLockContracts,
    };
}