arJWK
arJWK
Configuration item function
This configuration item is used to operate the everPay arweave account model account via arweave wallet and to do the following for the account
- deposit: transfer ar token on arweave blockchain to everPay locker address(Using Threshold cryptosystem) using
arJWK
- transfer: use
arJWK
to call arweaveRSA-PSS SHA-256
sign to secure access to the everPay account - withdraw: use
arJWK
to call arweaveRSA-PSS SHA-256
sign to secure access to the everPay account
Configuration item function
everpay-js integrates with arweave-js for signing and sending transactions with arweave.
Configuration item type
export type ArJWK = JWKInterface | 'use_wallet'
Uses arweave-js JWKInterface
as one of the type, and with a 'use_wallet'
string as a parameter for adapting Chrome arweave Plugin wallet ArConnect (a MetaMask-like wallet tool).
How to configure
JWKInterface mode
Reference from arweave Docs - Sample JWK
The arweave's private key format, a KEY JSON, e.g.
const arAddress = 'GRQ7swQO1AMyFgnuAPI7AvGQlW3lzuQuwlJbIpWV7xk'
const arJWK = {
kty: 'RSA',
e: 'AQAB',
n: 'ovFF6EbOtXeg7VnojIgtChgxfU6GZ16JjVj5JFHh6NGHJnq4p059BnMphcDx1mqb3yxM73FxhEszSFLcJiPzway6eIDiXuYiT-Sf_0Wl6_wDLvEmlz43psp7WYJumwpaSyiI_1FWmOVQnTnoAIKaOYKVqzUlteiECQj7XjJl0MZH16RlEfVqVpJ_8Ier4_QXIJ8Y3pe2KF3Lg9UANFU97nuvEM94CSzX-0WIju6Lykt3DBb2YtFFg4bJjOFv3T38nCZmDh8lYjm25_1qILalsB0XRoDxQy9FLxWb4zd09JsDhL0EYAQ_hNfOnQFVOBtYEHVYMCHYH6GoTcNgxmUkZPk4AfpAqZmjDzKfVJrw4Fr68pPTEQOQEzBcIWp61P21BSkhqO4QuFinkQsSH6NdTB_3FpbhYf34Hjf-iH7hdpdWo4aoRLb8eZeZcqBRZoRmlhQnOD-PVxQR_vb9rjXSjGkCWwRbsurVLWdBh_FQn0S9Q6EHqiV8nbW-R0Rk2E76JwgMFkqGUtZj8DeEqXJ2jlAvuzp56fXeAViPEtvUj1HheO8O3LxdVYCiapWWKq4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t3b9JJfPFMW3h38yQ_lrmKYZQfJQ',
qi: 'aDsPYxE-JBYsYhCYXSU7WsCrnFxNsRpFMcYXdmdryYIdQUpeemChDGzVJXLnJhE4cAS9TtLcNg82xZSKZvHrnkbFpRfSJxzEnvIXW4V0LHkxkxbmM0e9B7UrpYm6LKtvEY6I7L8wHFpHdOwV6NjY925oULEV156X0r55V7N0XF-jy3rbm71DCWRh6IDRghhCZQ3aNgJxE-OtnABqasaY6CQnTDRXLkGE0kq9GCx85-92fQLHMzvrMhr9m_2MHYJ_gZehL4j95CQzhD3Zh602D0YYYwRSsU4h5HGjlmN52pe-rfTLgwCJq5295s7qUP8TTMzbZAOM_hehksHpAaFghA'
}
const everpay = new Everpay({
account: arAddress,
chainType: 'arweave',
arJWK: arJWK
})
This method passes the private key explicitly in the code, which is a security risk
Browser + ArConnect
Once ArConnect is installed in the user's browser, you can use the pass arJWK: 'use_wallet'
to specify the use of ArConnect for arweave transfers (corresponding to everPay deposit), and signature (for everPay transfer and withdraw) operations.
const checkArPermissions = async (permissions: string[] | string): Promise<void> => {
let existingPermissions: string[] = []
const isString = (content: any) => {
return Object.prototype.toString.call(content) === "[object String]"
}
permissions = isString(permissions) ? [permissions] : permissions
try {
existingPermissions = await window.arweaveWallet.getPermissions()
} catch {
throw new Error('PLEASE_INSTALL_ARCONNECT')
}
if (permissions.length === 0) {
return
}
if (
permissions.some((permission) => {
return !existingPermissions.includes(permission)
})
) {
await window.arweaveWallet.connect(permissions as never[])
}
}
await checkArPermissions([
'ACCESS_ADDRESS',
'ACCESS_ALL_ADDRESSES',
'ACCESS_PUBLIC_KEY',
'SIGN_TRANSACTION',
'SIGNATURE'
])
const arAddress = await window.arweaveWallet.getActiveAddress()
const everpay = new Everpay({
account: arAddress,
chainType: 'arweave',
arJWK: 'use_wallet'
})
Why do I need to use use_wallet
?
- arweave-js also supports using
'use_wallet'
as ajwk
parameter on the browser side to get the arweave wallet address using ArConnect, and to do arweave transfer, signature. See arweave-js Search - use_wallet for details - everpay-js integrates with arweave-js to do arweave transfer, using
'use_wallet'
allows arweave-js to call ArConnect, thus reducing the cost of adapting ArConnect for developers. - On the web side, it is more secure to use ArConnect represented by
'use_wallet'
.