Post
Topic
Board Service Announcements (Altcoins)
Re: [ANN] Crypti Dapp Store | Decentralized Application Store for the Crypti Network
by
crypti
on 14/10/2015, 19:10:46 UTC
Hello,

I'm following along the tutorial that demonstrates how to create a simple messaging app. Everything has been going great, but I have bumped into a couple of problems/confusion on this page:

Quote

Specifically, where does the code go that is described under "After our validation passes, we need to generate a key pair. To do this, we use modules.api.crypto.keypair". Is it in the callback of Message.prototype.add like this:

Code:
Message.prototype.add = function (cb, query) {
    // Validate query object
    library.validator.validate(query, {
        type: "object",
        properties: {
            recipientId: {
                type: "string",
                minLength: 1,
                maxLength: 21
            },
            secret: {
                type: "string",
                minLength: 1,
                maxLength: 100
            },
            message: {
                type: "string",
                minLength: 1,
                maxLength: 160
            }
        }
    }, function (err) {
        // If error exists, execute callback with error as first argument
        if (err) {
            return cb(err[0].message);
        }
       
        var keypair = modules.api.crypto.keypair(query.secret);
modules.blockchain.accounts.getAccount({
        publicKey: keypair.publicKey.toString('hex')
    }, function (err, account) {
        // If error occurs, call cb with error argument
        if (err) {
            return cb(err);
        }
       
// Create new transaction
try {
    var transaction = library.modules.logic.transaction.create({
        type: self.type,
        message: query.message,
        recipientId: query.recipientId,
        sender: account,
        keypair: keypair
    });
} catch (e) {
    // Catch error if something goes wrong
    return setImmediate(cb, e.toString());
}

// Send transaction for processing
modules.blockchain.transactions.processUnconfirmedTransaction(transaction, cb);           
    });       
       
    });
}

A second issue I am having is with the command:
Code:
crypti-cli dapps --deposit
. I get the following error:

Quote
{ [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' } undefined
Error: connect ECONNREFUSED

Is this a port/firewall issue or something else?

Finally, I am getting an error when trying to run the PUT for the first message:

Code:
curl -XPUT -H "Content-type: application/json" -d '{
"recipientId": "58191895912485C",
"message": "Hello, world!",
"secret": "mysecret"
}' 'http://[my_domain_and_port]/api/dapps/[dappid]/api/messages/add'

Error:

Quote
Cannot PUT /dapps/1719096962757412325/api/messages/add

Does the recipientId have to be something specific, or can it be any string? Any idea how to debug that?

Thanks!

Baz

1. Recipient must be Crypti address or your address.
2.

Quote
Cannot PUT /dapps/1719096962757412325/api/messages/add

Did you restarted crypti when updated code? Did you have Crypti enabled when trying deposit? And did you added api calls to routes.json file? Thanks for answers. Meanwhile i will try it.