Git Product home page Git Product logo

splinterlands-js's Introduction

Client-Side JS SDK for Splinterlands

CDN URLs

<script src="https://cdn.jsdelivr.net/gh/steem-monsters/splinterlands-js@master/dist/splinterlands.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/steem-monsters/splinterlands-js@master/dist/splinterlands.min.css" />

Init

Initializes the SDK with the API server URL and WebSocket server URL.

// Production URLs
await splinterlands.init({ api_url: 'https://steemmonsters.com', ws_url: 'wss://ws.steemmonsters.io' });

// QA Site URLs
await splinterlands.init({ api_url: 'https://testnet.steemmonsters.io', ws_url: 'wss://sm-ws.mrosen.com' });

Login

Log in to the game using a Steem blockchain account.

If no parameters are specified, it will attempt to log in using the login information stored in the browser's local storage. The has_saved_login() method can be used to check whether or not the user has credentials stored locally in the browser.

if(splinterlands.has_saved_login()) {
	// Attempt to log in using saved credentials
	let login_response = await splinterlands.login();

	if(!login_response.error) {
		// If there is no error, the user was successfully logged in and you can proceed to show the home screen
		// The "login_response" variable will contain the player information returned by the server
	} else {
		// If there was an error, just show the log in screen
	}
}

If only a username is specified, it will attempt to log in using the Steem Keychain browser extension which securely stores the Steem account passwords. Finally, if both a username and a password are specified, it will use that information to attempt to log in.

// Attempt to log in using saved credentials
let login_response = await splinterlands.login(username, password (optional));

if(login_response.error) {
	// Display the error message to the user
} else {
	// Proceed to show the home screen. The "login_response" variable will contain the player information returned by the server
}

splinterlands-js's People

Contributors

melonman0 avatar mattyice avatar daveghazaryan avatar investygator avatar taron-iritsyan avatar antiosh avatar drewwells avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.