1. Project Overview & Quickstart (teamchong/MODEL_RENDER_PROFILES)
MODEL_RENDER_PROFILES
Open-source repository teamchong/MODEL_RENDER_PROFILES
Repository Details
- Repository: teamchong/MODEL_RENDER_PROFILES
- Primary Language: Code
Note: High-volume repository documentation is actively indexed and synchronized by YakaAI.
2. Official Technical Reference & Guides (teamchong/docs)
File: README.md
Introduction
Phantom is a wallet and browser extension that can be used to manage digital assets and access decentralized applications on the Solana blockchain.
It works by creating and managing private keys on behalf of its users, allowing them to store funds and sign transactions.
The extension injects a solana object into the javascript context of every web application the user visits. The application may then interact with the wallet, such as asking for permission to perform a transaction, through this injected object.
File: faq.md
FAQ
Are hardware wallets supported?
Yes, currently Ledger is supported and requires no special treatment on the application side.
File: sandbox.md
Sandbox
For a live example of a simple Phantom integration, check out our developer sandbox on Codesandbox and GitHub.
File: SUMMARY.md
Table of contents
Integrating
Resources
File: integrating/detecting-the-provider.md
Detecting the Provider
The Phantom browser extension will inject an object calledsolana on the window object of any web application the user visits.
To detect if a browser extension using this API is installed, you can check for the existence of the solana object.
To make it easy to detect Phantom specifically, the extension will add an additional isPhantom flag.
const isPhantomInstalled = window.solana && window.solana.isPhantomIf Phantom is not installed, we recommend you redirect your users to our website. Altogether, this may look like the following.
const getProvider = () => {
if ("solana" in window) {
const provider = window.solana;
if (provider.isPhantom) {
return provider;
}
}
window.open("https://phantom.app/", "_blank");
};File: integrating/establishing-a-connection.md
Establishing a Connection
In order to start interacting with Phantom you must first establish a connection. This connection request will prompt the user for permission to share their public key, and indicate that they are willing to interact further.
Once permission is established the first time, the web application's domain will be whitelisted for future connection requests. The user may also indicate that they are willing to auto-approve certain transactions from the application as well.
Similarly, it is possible to terminate the connection both on the application and the user side.
Connecting
The recommended and easiest way to connect to Phantom is by calling window.solana.connect() . However, the provider also exposes a request JSON RPC interface.
{% tabs %}
{% tab title="connect()" %}
window.solana.connect();{% endtab %}
{% tab title="request()" %}
window.solana.request({ method: "connect" }){% endtab %}
{% endtabs %}
When the user has accepted the request to connect, the provider will emit a connect event.
window.solana.on('connect' () => console.log("connected!"))Once the web application is connected to Phantom, it will be able to read the connected account's public key and send transactions. It also exposes a convenience isConnect boolean, and will indicate whether automatic transaction approvals have been enabled by the user.
window.solana.publicKey.toString()
// 26qv4GCcx98RihuK3c4T6ozB3J7L6VwCuFVc7Ta2A3Uo
window.solana.isConnect
// true
window.solana.autoApprove
// true or falseDisconnecting
Disconnecting is similar to connecting, however, it is possible for the disconnection to originate from the wallet.
{% tabs %}
{% tab title="disconnect()" %}
window.solana.disconnect();{% endtab %}
{% tab title="request()" %}
window.solana.request({ method: "disconnect" });{% endtab %}
{% endtabs %}
window.solana.on('disconnect' () => console.log("disconnected!"))File: integrating/live-integrations.md
Live Integrations
Phantom is integrated in major Solana projects, many of which are open source. Here are some examples.
File: integrating/sending-a-transaction.md
Sending a Transaction
Once the web application is connected to Phantom, it can send transactions on behalf of the user, with the user's permission.
In order to send a transaction, the web application must:
- Create an unsigned transaction or transactions.
- Have it be signed by the user's Phantom wallet.
- Send it to a Solana node for processing.
For more information about the nature of transactions on Solana, it is recommended to review the solana-web3.js docs as well as the official Solana docs.
For a sample transaction check out our developer sandbox.
{% page-ref page="../sandbox.md" %}
Signing a Transaction
Once a transaction is created, the web application may ask the user's Phantom wallet to sign the transaction using their account's private key. By far the easiest and recommended way of doing this is by using the signTransaction method on the provider, but it is also possible to do with request. In both cases, the call with return a Promise for the signed transaction.
{% tabs %}
{% tab title="signTransaction()" %}
const network = "<NETWORK_URL>";
const connection = new Connection(network);
const transaction = new Transaction();
const signedTransaction = await window.solana.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());{% endtab %}
{% tab title="request()" %}
const network = "<NETWORK_URL>";
const connection = new Connection(network);
const transaction = new Transaction();
const signedTransaction = await window.solana.request({
method: "signTransaction",
params: {
message: bs58.encode(transaction.serializeMessage()),
},
});
const signature = await connection.sendRawTransaction(signedTransaction.serialize());{% endtab %}
{% endtabs %}
Signing Multiple Transactions
It is also possible to sign and send multiple transactions at once. This is exposed through the signAllTransactions method on the provider.
{% tabs %}
{% tab title="signAllTransactions()" %}
const signedTransactions = await window.solana.signAllTransactions(transactions);{% endtab %}
{% tab title="request()" %}
const message = transactions.map(transaction => {
return bs58.encode(transaction.serializeMessage());
});
const signedTransactions = await window.solana.request({
method: "signAllTransactions",
params: { message },
});{% endtab %}
{% endtabs %}