The "Deploy Contract" feature in the KrypC wallet-dev Service API enables users to seamlessly deploy smart contracts on the blockchain, facilitating the creation and execution of decentralised applications.
This Deploys contract using this method.
To deploy Contract API under the given instance.
200: OK SUCCESS 401: Unauthorized Failure in authentication 500: Internal Server Error Key values are not given
Copy
{
"Data" : {
"contractAddress" : "0xAa79a01409D842aD3F6ec0xxxxxxxxxxxxxxx" ,
"txHash" : "0x1cd443b4573eddcd5e518d1ab31916xxxxxxxxxxxxxxxxxxxxx"
} ,
"Message" : "Signed and executed txn successfully" ,
"Status" : "SUCCESS"
}
Copy {
"message": "Invalid API key in request"
}
Copy {
"message" : "Internal Server Error"
}
Take a look at how you might call this method using our official libraries, or via curl
Here, "abi" will be in json format which we need to convert to base64.
curl Node.js (Axios) Python Golang
Copy
curl --location 'https://api.krypcore.com/api/v0/devWallet/deployContract' \
--header 'DappId: **********' \
--header 'Authorization: **********' \
--header 'SubscriptionId: ********' \
--header 'ChainId: ********' \
--header 'Content-Type: application/json' \
--data '{
"service": "easy-nft",
"privateKey": "**********",
"byteCode":" ",
"abi":" ",
"params":[],
"chainId":80001
}'
Copy
var myHeaders = new Headers ();
myHeaders .append ( "DappId" , "**********" );
myHeaders .append ( "Authorization" , "**********" );
myHeaders .append ( "SubscriptionId" , "********" );
myHeaders .append ( "ChainId" , "********" );
myHeaders .append ( "Content-Type" , "application/json" );
var raw = JSON .stringify ({
"service" : "easy-nft" ,
"privateKey" : "**********" ,
"byteCode" : " " ,
"abi" : " " ,
"params" : [] ,
"chainId" : 80001
});
var requestOptions = {
method : 'POST' ,
headers : myHeaders ,
body : raw ,
redirect : 'follow'
};
fetch ( "https://api.krypcore.com/api/v0/devWallet/deployContract" , requestOptions)
.then (response => response .text ())
.then (result => console .log (result))
.catch (error => console .log ( 'error' , error));
Copy
import requests
import json
url = "https://api.krypcore.com/api/v0/devWallet/deployContract"
payload = json . dumps ({
"service" : "easy-nft" ,
"privateKey" : "**********" ,
"byteCode" : " " ,
"abi" : " " ,
"params" : [],
"chainId" : 80001
})
headers = {
'DappId' : '**********' ,
'Authorization' : '**********' ,
'SubscriptionId' : '********' ,
'ChainId' : '********' ,
'Content-Type' : 'application/json'
}
response = requests . request ( "POST" , url, headers = headers, data = payload)
print (response.text)
Copy
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main () {
url := "https://api.krypcore.com/api/v0/devWallet/deployContract"
method := "POST"
payload := strings. NewReader ( `{
"service": "easy-nft",
"privateKey": "**********",
"byteCode":" ",
"abi":" ",
"params":[],
"chainId":80001
}` )
client := & http.Client {
}
req, err := http. NewRequest (method, url, payload)
if err != nil {
fmt. Println (err)
return
}
req.Header. Add ( "DappId" , "**********" )
req.Header. Add ( "Authorization" , "**********" )
req.Header. Add ( "SubscriptionId" , "********" )
req.Header. Add ( "ChainId" , "********" )
req.Header. Add ( "Content-Type" , "application/json" )
res, err := client. Do (req)
if err != nil {
fmt. Println (err)
return
}
defer res.Body. Close ()
body, err := ioutil. ReadAll (res.Body)
if err != nil {
fmt. Println (err)
return
}
fmt. Println ( string (body))
}