0xSU - Ethereum Short URLs (JS Lib)
Finally, the thing you've been waiting for your entire adult life. Decentralized URL shortener. It's like goo.gl
except it can't be taken down. It's hosted on QuikNode and integrated with Wyre. This is the JS client you can use for integration with your web3 front-end.
Install: npm install @jonbiro/0xsu-js-lib --save
Here's how it works:
import Du4e from '@jonbiro/0xsu-js-lib'
let oxsu = new Du4e()
Then it will automatically ask for permissions when necessary and pick up the appropriate version of web3. Now you can do things like, get the long version of a link based on a short slug:
const short = "0x397997"
oxsu.getUrl(short).then(url => {
console.log(url)
})
let url = await oxsu.getUrl(short)
or if you want to redirect the browser:
oxsu.forward("0x397997")
or just shorten a URL:
const url = "https://twitter.com/ETHNewYork/status/1125830316730519556"
await oxsu.shortenURL(url)
oxsu.shortenURL(
url,
{
slug: "vitalik",
acct: "0x31D583a494af597B53eB49B62FCaAb4BAF7f2e69",
cb: (txID) => {
console.log("0xSU TX ID: ", txID)
}
}
)
and then you can listen for a shortenedURL:
oxsu.onURLShorten = (slug) => {
console.log("Slug is ", slug)
}
or grab all the shortened URLs for a particular Ethereum account:
oxsu.listOfUrls((urls) => {
console.log(urls)
})
oxsu.listOfUrls("0x31D583a494af597B53eB49B62FCaAb4BAF7f2e69", (urls) => {
console.log(urls)
})
Thanks. This project was made by @jonathanbiro and @bunsen