I have a derivation scheme starting with tpub... for testnet and I want to be able to generate bitcoin addresses from derivation scheme. Also I want a method be applicable to mainnet, is any library available that could help me in this task. And code example how to do it what be great. I was thinking bitcore-lib would help, but didn't found anything useful for my task. But any solution would be fine. All useful information I found was a bunch of bips, but I doubt that I need to do that from scratch, and want to avoid it.
Have a time to publish a full answer now:
var runningNetwork = bjs.networks.testnet
const bip32 = require('bip32')
const bjs = require('bitcoinjs-lib')
let { address } = bjs.payments.p2wpkh({pubkey: bip32.fromBase58(dvScheme,runningNetwork).derive(0).derive(1).publicKey,})
console.log(`${address}`)
Related
I am trying to create an NFT using web3.js and spl-token.js.
However, i need to add meta data (like the name of the token or other attributes), otherwise it just shows up as "Unknown Token" in my wallet.
This is the relevant part of the code where I am minting the token:
let mint = await splToken.Token.createMint(
connection,
fromWallet,
fromWallet.publicKey,
null,
0,
splToken.TOKEN_PROGRAM_ID
);
Otherwise the code is similar to the answers on this question: I would like to mint a new token on solana. How can I do this using solana-web3.js?
There does not seem to be any documentation whatsoever, except for the structure of the meta data (which I found here: https://docs.phantom.app/integrating/tokens/on-chain-metadata).
If anyone could point me in the right direction with an example or documentation it would be really much appreciated. Thank you!
In order to add metadata to NFT you need to invoke this program spl_token_metadata::instruction::create_metadata_accounts. You can find the documentation here.
PS: The example above is in Rust. To do it in JavaScript is like that:
import { Metaplex, keypairIdentity } from "#metaplex-foundation/js";
const metaplex = new Metaplex(connection);
metaplex.use(keypairIdentity(keypair));
const mintNFTResponse = await metaplex.nfts().create({
uri: "https://ffaaqinzhkt4ukhbohixfliubnvpjgyedi3f2iccrq4efh3s.arweave.net/KUAIIbk6p8oo4XHRcq0U__C2r0mwQaNl0gQow4Qp9yk",
maxSupply: 1,
});
Like described here is another exemple.
Create a metadata for an NFT token in Solana is quite complicated. It is because in Solana SPL-token account would not carry the Metadata. Instead, you have to create another account to carry such data. So, I suggest you to use Metaplex's Candy Machine to make your own NFT with Metadata. You may get more information from their github:
https://github.com/metaplex-foundation/metaplex/
I do not know why with this, even though in the previous version (web3 + Metamask) can issue real data. But now used as hashing (output). I took the example in the code and output below (to get the TotalSupply on the ERC20 Token):
Output : 0x18160ddd
const contractInstance = web3.eth.contract(contractAbi).at(contractAddress);
const total_supply = contractInstance.totalSupply.getData();
console.log(total_supply);
How to showing real data? In a sense it doesn't come out hashing. Thanks
.getData() returns the ABI-encoded input you would have to send to the smart contract to invoke that method.
If you want to actually call the smart contract, use .call() instead.
I don't understand this documentation, I tried so hard to do the mentioned info below but I am not quite sure what "jsonApiURL" is. Can someone tell me how to properly achieve the goal in the quote.
Response Format
You can request specific related resources and or resource attributes
that you want returned by our API, as per the JSON:API specification.
The lists of valid includes and fields arguments are provided in
patreon/schemas. For instance, if you wanted to request the total
amount a patron has ever paid to your campaign, which is not included
by default, you could do:
const patreonAPIClient = patreonAPI(access_token)
const url = jsonApiURL(`/current_user`, {
fields: {
pledge: [...pledge_schema.default_attributes, pledge_schema.attributes.total_historical_amount_cents]
}
})
patreonAPIClient(url, callback)
More info below
https://github.com/Patreon/patreon-js
Ok guys. I've built a web application with some friends that is somehow complex and took us some time to built. It is entirely built using JavaScript
Now the application has some functions which we don't want to readily share with the world(view-source).
The application works by sending an input to an algorithm and receiving the output from that algorithm and displays it on a canvas. (Thats how all functions work anyway:) )
Okay i don't know much about node.js but from what i've heard its server-side JavaScript. Does that mean that i can transfer the function server-side and using POST-GET to send an input and receive an output? All without having the source code of that particular function readily visible to anyone?
Please don't get started about how i should be more worried about doing things better rather than worrying about the safety of our work. I already know that so consider my question as a complimentary safeguard, at least for the time being.
Obfuscation is not a very concrete option since many developers de-obfuscate code just for fun.
This application is not like a hen with a golden egg and i am not being grandiose about this, but i was just having this question in my mind for some time now so i just shoot it here to know in the future how things work.
Thanks guys!
If you're worried about protecting your ultra sweet super secret codes, you could host your app and use a little something called RPC. Remote. Procedure. Calls.
Check out this little guy
https://github.com/deoxxa/pillion
Easy as 1-2-3 or A-B-C or cake or strippers or whatever else is easy
% npm install pillion burro && echo omg that was so easy
DISCLAIMER
I'm about to reveal a super secret greeting function that says hello to our clients. This is ultra secret intellectual IP properties and should not be shared with anyone on the internets.
You could provide the function calls you need using something like this on the server
// server.js
var net = require("net"),
burro = require("burro"),
pillion = require("pillion");
var server = net.createServer(function(_socket) {
var socket = burro.wrap(_socket),
rpc = new pillion(socket);
rpc.provide("greet", function(name, cb) {
cb("hi there, " + name);
});
});
server.listen(3000);
Then on the client side
// client.js
var net = require("net"),
burro = require("burro"),
pillion = require("pillion");
var _socket = net.connect(3000),
socket = burro.wrap(_socket),
rpc = new pillion(socket);
rpc.callRemote("greet", "friend", function(res) {
console.log(res); // prints "hi there, friend"
});
ok, I'm finally at my wits' end. I have a have an XMPP server (Openfire) running, and trying to connect via JavaScript using JSJaC. The strange thing is that I can establish a connection for some users, but not for all. I can reproduce the following behavior: create two accounts (username/password), namely r/pwd and rr/pwd with the result:
r/pwd works
rr/pwd doesn't work.
So far, each account with a user name consisting of only one character works. This is strange enough. On the other side, old accounts, e.g., alice/a work. The whole connection problem is quite new, and I cannot trace it to any changes I've made.
And to make my confusion complete with any instant messenger supporting XMPP, all accounts work, incl., e.g., rr/pwd. So assume, the error must be somewhere in my JavaScript code. Here's he relevant snippet:
...
oArgs = new Object();
oArgs.domain = this.server;
oArgs.resource = this.resource;
oArgs.username = "r";
oArgs.pass = "pwd";
this.connection.connect(oArgs);
The code above works, but setting oArgs.username = "rr", and it fails.
I would be grateful for any hints. I'm quite sure that it must be something really stupid I miss here.
Christian
Adding oArgs.authtype = 'nonsasl' to the argument list when creating the xmpp connection using JSJaC solved my problem. I haven't tried Joe's command to alter the SASL settings in Openfire; I'm scared to ruing my running system :).