Solana Provider
You can interact with Solana blockchains using @solana/web3.js together with the Wepin Provider.
Supported Networks
Installation
Once the installation is complete, initialize the WepinProvider instance using the app ID and app key assigned after registering the app. This will enable the use of WepinProvider.
Initialization
Here's how to initialize the Wepin Provider.
init
Parameters
attributes
<object> optionaldefaultLanguage
: The language to be displayed on the widget (default:'ko'
) Currently, only'ko'
and'en'
are supported.defaultCurrency
: The currency to be displayed on the widget (default:'KRW'
) Currently, only'KRW'
and'USD'
are supported.
Return value
Promise
<void>
Example
isInitialized
It checks if WepinProvider is initialized properly.
Parameters
<void>
Return value
<boolean>
Returnstrue
if init was successful, otherwise returnsfalse
.
Example
changeLanguage
It allows changing the language and currency of the widget.
Parameters
attributes
<object>language
<string> It specifies the language to be displayed on the widget. Currently supported languages areen
andko
.currency
<string> It specifies the currency to be displayed on the widget. Currently supported currencies areUSD
andKRW
.
Return value
<boolean> It returns
true
if the change was successful, otherwise returnsfalse
.
Example
Methods
Methods can be used after initializing the Wepin Provider.
getProvider
It returns the provider for the specified network.
Parameters
network
<string> It's the network variable value of the provider supported by Wepin. It should be entered in lowercase.
Return value
Promise
<BaseProvider> - A solana provider
Example
finalize
It terminates the use of WepinProvider.
Parameters
<void>
Return value
<void>
Example
request
You can send JSON-RPC requests to interact with the Solana blockchain.
connect
Connects to the Wepin Wallet and requests permission to share the user's account address (Public Key). Once the connection is approved, the application can make further requests, such as signing messages or transactions
Parameters
<void>
Return value
Promise
<object>publicKey
<string> - Solana Account's Address(Public Key)
Example
signTransaction
Signs a serialized transaction. Takes the transaction as a hex string and returns the signed transaction.
Parameters
<object>
message
<string> - A transaction serialized and converted to a hex string.
Return value
Promise
<Transaction> - A Transaction that includes a signature.
Example
signAndSendTransaction
Signs and submits the serialized transaction to the Solana network. Returns the signature of the transaction.
Parameters
<object>
message
<string> - A transaction serialized and converted to a hex string.
Return value
Promise
<object>signature
<TransactionSignature> - The signature of the Transaction.
Example
signMessage
Signs a message with a specified account's address (Public Key). Takes the account address and the message to be signed as input.
Parameters
<array>
<string>
- The address (Public Key) of the account that signs the transaction.<string>
- The message to be signed.
Return value
Promise
<Transaction> - A Transaction that includes a signature.
Example
changeNetwork
Switches the network. Supports switching between Solana Mainnet and Devnet, and returns the address, network name, and chain ID of the switched network.
Parameters
<object>
chainId
<string> - The chainId of the network to switch to. Only Solana chains (solana , solana ) are supported.
Return value
Promise
<object>address
<string> - The account address (Public Key) on the switched network.network
<string> - The name of the switched network.chainId
<string> - The chain ID of the switched network.
Example
For more details on Solana network providers, please refer to the link below.
Last updated