프로바이더 메서드
`getProvider()`를 사용하여 프로바이더를 얻은 후에는, 다음 메서드들을 사용할 수 있습니다:
request
await provider.request({ method, params });Parameters
Return value
Example
const provider = await wepinProvider.getProvider('ethereum');
// Get connected accounts
const accounts = await provider.request({
method: 'eth_requestAccounts',
});
console.log('Connected accounts:', accounts);
// Sign message
const signature = await provider.request({
method: 'eth_sign',
params: ['0x...', 'Hello, world!'],
});
// Personal sign
const personalSignature = await provider.request({
method: 'personal_sign',
params: ['Hello, World', '0x...'],
});
// Sign typed data v4
const typedDataV4 = {
types: {
EIP712Domain: [{ name: 'name', type: 'string' }],
Mail: [{ name: 'contents', type: 'string' }],
},
primaryType: 'Mail',
domain: { name: 'Ether Mail' },
message: { contents: 'Hello, Bob!' },
};
const typedSignature = await provider.request({
method: 'eth_signTypedData_v4',
params: ['0x...', typedDataV4],
});
// Send transaction
const transaction = {
from: '0x...',
to: '0x...',
value: '0x0',
data: '0x',
};
const txHash = await provider.request({
method: 'eth_sendTransaction',
params: [transaction],
});Last updated
Was this helpful?