
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@stacks/connect
Advanced tools
@stacks/connect
[!NOTE] The
7.x.x
version may still be more well supported by some wallets.
For the legacy version of @stacks/connect
using JWT tokens, please use the following command:
npm install @stacks/connect@7.10.1
@stacks/connect
npm install @stacks/connect
pnpm install @stacks/connect
yarn add @stacks/connect
request
to trigger wallet interactions import { request } from '@stacks/connect';
// CONNECT
const response = await request({ forceWalletSelect: true }, 'getAddresses');
getAddresses
stx_getAddresses
stx_getAccounts
stx_transferStx
stx_callContract
stx_deployContract
stx_signMessage
stx_signStructuredMessage
getAddresses
const response = await request('getAddresses');
// {
// "addresses": [
// {
// "address": "bc1pp3ha248m0mnaevhp0txfxj5xaxmy03h0j7zuj2upg34mt7s7e32q7mdfae",
// "publicKey": "062bd2c825300d74f4f9feb6b2fec2590beac02b8938f0fc042a34254581ee69",
// },
// {
// "address": "bc1qtmqe7hg4etkq4t384nzg0mrmwf2sam9fjsz0mr",
// "publicKey": "025b65a0ec0e00699794847f2af1b5d8a53db02a2f48e09417598bef09cfea1114",
// },
// {
// "address": "SP2MF04VAGYHGAZWGTEDW5VYCPDWWSY08Z1QFNDSN",
// "publicKey": "02d3331cbb9f72fe635e6f87c2cf1a13cdea520f08c0cc68584a96e8ac19d8d304",
// }
// ]
// }
stx_getAddresses
const response = await request('stx_getAddresses');
// {
// "addresses": [
// {
// "address": "bc1pp3ha248m0mnaevhp0txfxj5xaxmy03h0j7zuj2upg34mt7s7e32q7mdfae",
// "publicKey": "062bd2c825300d74f4f9feb6b2fec2590beac02b8938f0fc042a34254581ee69",
// },
// {
// "address": "bc1qtmqe7hg4etkq4t384nzg0mrmwf2sam9fjsz0mr",
// "publicKey": "025b65a0ec0e00699794847f2af1b5d8a53db02a2f48e09417598bef09cfea1114",
// },
// {
// "address": "SP2MF04VAGYHGAZWGTEDW5VYCPDWWSY08Z1QFNDSN",
// "publicKey": "02d3331cbb9f72fe635e6f87c2cf1a13cdea520f08c0cc68584a96e8ac19d8d304",
// }
// ]
// }
stx_getAccounts
const response = await request('stx_getAccounts');
// {
// "addresses": [
// {
// "address": "SP2MF04VAGYHGAZWGTEDW5VYCPDWWSY08Z1QFNDSN",
// "publicKey": "02d3331cbb9f72fe635e6f87c2cf1a13cd...",
// "gaiaHubUrl": "https://hub.hiro.so",
// "gaiaAppKey": "0488ade4040658015580000000dc81e3a5..."
// }
// ]
// }
stx_transferStx
const response = await request('stx_transferStx', {
amount: '1000', // amount in micro-STX (1 STX = 1,000,000 micro-STX)
recipient: 'SP2MF04VAGYHGAZWGTEDW5VYCPDWWSY08Z1QFNDSN', // recipient address
network: 'mainnet', // optional, defaults to mainnet
memo: 'Optional memo', // optional memo field
});
// {
// "txid": "0x1234...", // The transaction ID
// }
stx_callContract
const response = await request('stx_callContract', {
contract: 'SP2MF04VAGYHGAZWGTEDW5VYCPDWWSY08Z1QFNDSN.counters', // contract in format: address.contract-name
functionName: 'count', // name of the function to call
functionArgs: [Cl.int(3)], // array of Clarity values as arguments
network: 'mainnet', // optional, defaults to mainnet
});
// {
// "txid": "0x1234...", // The transaction ID
// }
stx_deployContract
const response = await request('stx_deployContract', {
name: 'counters', // name of the contract
clarityCode: `(define-map counters principal int)
(define-public (count (change int))
(ok (map-set counters tx-sender (+ (get-count tx-sender) change)))
)
(define-read-only (get-count (who principal))
(default-to 0 (map-get? counters who))
)`, // Clarity code as string
clarityVersion: '2', // optional, defaults to latest version
network: 'mainnet', // optional, defaults to mainnet
});
// {
// "txid": "0x1234...", // The transaction ID
// }
stx_signMessage
const response = await request('stx_signMessage', {
message: 'Hello, World!', // message to sign
});
// {
// "signature": "0x1234...", // The signature of the message
// "publicKey": "02d3331cbb9f72fe635e6f87c2cf1a13cdea520f08c0cc68584a96e8ac19d8d304" // The public key that signed the message
// }
stx_signStructuredMessage
const clarityMessage = Cl.parse('{ structured: "message", num: u3 }');
const clarityDomain = Cl.tuple({
domain: Cl.stringAscii('example.com'),
version: Cl.stringAscii('1.0.0'),
'chain-id': Cl.uint(1),
});
const response = await request('stx_signStructuredMessage', {
message: clarityMessage, // Clarity value representing the structured message
domain: clarityDomain, // domain object for SIP-018 style signing
});
// {
// "signature": "0x1234...", // The signature of the structured message
// "publicKey": "02d3331cbb9f72fe635e6f87c2cf1a13cdea520f08c0cc68584a96e8ac19d8d304" // The public key that signed the message
// }
FAQs
Unknown package
The npm package @stacks/connect receives a total of 2,749 weekly downloads. As such, @stacks/connect popularity was classified as popular.
We found that @stacks/connect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.