Skip to content

Getting error while sendig test ADA from one address to another using exiting wallet ID #53

@SamirBitzees

Description

@SamirBitzees

I am following (https://developers.cardano.org/docs/get-started/cardano-wallet-js/) this document for development using cardano-wallet-js. And using below script for sendPayment, but getting error to send payments.

import {Address, WalletServer } from 'cardano-wallet-js';
//const walletId = "b2eaa569bf27180c9806783bdd75dd145e216ae2";
let walletServer = WalletServer.init('http://0.0.0.0:6002/v2');
let passphrase = 'tangocrypto';
let wallets = await walletServer.wallets();
let wallet = await walletServer.getShelleyWallet("b2eaa569bf27180c9806783bdd75dd145e216ae2"); let receiverAddress = [new Address('addr_test1qzhg95y7f9kh23qwu0hmnncs8lg3ezk2vw5980e27cmv2cn4r5r6cmxxf3qqhhz49shud34ye7ppk3gq5zu7gagd2wzs6v2zcs')];
let amounts = [5000000]; // 5 ADA
let transaction = await wallet.sendPayment(receiverAddress,amounts,passphrase);

Error:---
ubuntu@ip-172-31-44-6:~/cardano-git-repo/cardano_raw_api/scripts$ node sendtoaddress.js
/home/ubuntu/cardano-git-repo/cardano_raw_api/node_modules/axios/lib/core/createError.js:16
var error = new Error(message);
^

Error: Request failed with status code 400
at createError (/home/ubuntu/cardano-git-repo/cardano_raw_api/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/ubuntu/cardano-git-repo/cardano_raw_api/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/ubuntu/cardano-git-repo/cardano_raw_api/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (node:events:529:35)
at endReadableNT (node:internal/streams/readable:1368:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
config: {
url: 'http://0.0.0.0:6002/v2/wallets/b2eaa569bf27180c9806783bdd75dd145e216ae2/transactions',
method: 'post',
data: '{"passphrase":[{}],"payments":[{"amount":{"unit":"lovelace","quantity":"t"}}]}',
headers: {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/json',
'User-Agent': 'axios/0.21.4',
'Content-Length': 78
},
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
}
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
finish: [Function: requestOnFinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 78,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: <ref *2> Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: null,
_closeAfterHandlingError: false,
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: false,
endEmitted: false,
reading: true,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: true,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions