QuantumMechanics / NEM-sdk

NEM Developer Kit for Node.js and the browser
MIT License
137 stars 82 forks source link

Error in creating Mosaic using nem-sdk (javascript) #59

Open johnmackyllego opened 6 years ago

johnmackyllego commented 6 years ago

Error message: { code: 0, data: { timeStamp: 114514807, error: 'Internal Server Error', message: 'org.nem.core.serialization.SerializationException: java.lang.IllegalArgumentException: name does not match the desired pattern', status: 500 } }

our source code: ` createMosaic : function(){ var privateKey = '7bfb69ab63df2a7ab4c690b206ddc4538dfae07e5cde4919dbe4ff385c6aff2a'; //var namespaceId = 'Brgy';
var mosaicName ='MoneyGram'; var initialSupply = 1000; var divisibility = 2; var transferable = true; var supplyMutable = true; var common = nem.model.objects.create('common')('', privateKey);

    // Get a MosaicDefinitionCreationTransaction object
    var tx = nem.model.objects.get("mosaicDefinitionTransaction");
    // Define the mosaic
    tx.mosaicName = mosaicName;
    tx.namespaceParent = {
        "fqn": "nanomoto"
    };
    tx.mosaicDescription = 'My mosaic';

    // Set properties (see https://nemproject.github.io/#mosaicProperties)
    tx.properties.initialSupply = initialSupply;
    tx.properties.divisibility = divisibility;
    tx.properties.transferable = transferable;
    tx.properties.supplyMutable = supplyMutable;
    tx.levy = {};
    //console.log(tx);

    // Prepare the transaction object
    var transactionEntity = nem.model.transactions.prepare("mosaicDefinitionTransaction")(common, tx, nem.model.network.data.testnet.id);
    console.log(transactionEntity);
    nem.model.transactions.send(common, transactionEntity, endpoint).then(function(res){
        console.log(res);
    },
        function(err){
        console.log(err);
    });

},`

We follow the instruction here: https://github.com/QuantumMechanics/NEM-sdk/blob/master/examples/nodejs/createMosaic.js#L19

riyazlafir commented 5 years ago

@johnmackyllego please try mosaic name with lower case letters. instead of this tx.mosaicName = mosaicName;

try, tx.mosaicName = mosaicname;

This solved the same issue which I had.

Cheers.