1. Create a Smart Contract
2. Connect to the Lamden Wallet
3. Interact with your Contract
Lamden Wallet API
Now it’s time to send your transaction.
In this example we’re painting a pixel on the paint method on the contract we approved in step 2. We’re painting the pixel at x=3 and y=14 to be #aaff00.
const detail = JSON.stringify({
//Which Lamden Network to send this to
//mainnet, testnet are the only acceptable values
networkType: 'mainnet',
//The method in your contract to call
methodName: 'paint',
//The argument values for your method
kwargs: {
x: 3,
y: 14,
c: #aaff00
},
//The maximum amount of stamps this transaction is allowed to use
//Could use less but won't be allowed to use more
stampLimit: 10
});
document.dispatchEvent(new CustomEvent('lamdenWalletSendTx', {detail}));
That’s it! Your transaction has been posted to the blockchain.
Pending your users approval of course.
Learn More about the Lamden Wallet API »
4. Get Results from the Blockchain
Lamden Masternode API
Now, if we wanted to get the state from the contract for a certain pixel, we could simply send a request to the REST Lamden Masternode API.
Obviously, we don’t want to be sending a million requests to the API for the whole pixel grid, but this is a good starting off point for developing your app.
To get the data for the pixel at x=0 and y=0 we just send a request to:
https://masternode-01.lamden.io/contracts/con_paint/data?key=0:0
And here’s the response:
{"value":"#a83d10"}
Alternatively we could have used contracting to get the state of the contract, or used the Lamden Wallet API to get the status of any of the transactions we sent earlier.
Simple! It’s easy-to-use powerful tools like these that make creating decentralised applications with Lamden as simple as creating traditional applications.
Next Steps