ontio / ontology-go-sdk Goto Github PK
View Code? Open in Web Editor NEWSDK for Ontology
SDK for Ontology
Currently, the guidelines say to have commit messages be numerous sections and potentially paragraphs. I think it would be better practice to follow the 50/72 formatting:
For these reasons, the "summary" must be no more than 70-75
characters, and it must describe both what the patch changes, as well
as why the patch might be necessary. It is challenging to be both
succinct and descriptive, but that is what a well-written summary
should do.
The commit message for my PR is 101 characters and GitHub even cuts it off at 70 characters. I think it would be better to change the guidelines so that the pull requests answer certain questions (like what they are fixing, why, etc).
It should also be noted that the people should be using git commit --signoff.
假设: a 向 b 转账 1 ONT,通常是a地址扣除1ONT,0.01ONG, b地址收到1ONT
看见java sdk中可以设置 gas 的扣费地址,是不是说 可以设置为 0.01ONG由 C 地址扣除
gosdk中, MutableTransaction
也可以设置Payer
type MutableTransaction struct {
Version byte
TxType TransactionType
Nonce uint32
GasPrice uint64
GasLimit uint64
Payer common.Address
Payload Payload
//Attributes []*TxAttribute
attributes byte //this must be 0 now, Attribute Array length use VarUint encoding, so byte is enough for extension
Sigs []Sig
}
那么怎么构造这样的交易呢?
Hi, I use FetchTxTransferEvent to get oep4 token tx, but find 'from' and 'to' address is not correct. then i debug and find parseOep4TransferEvent parse address has some problem, the hex string is reversed. can somebody make sure this?
I am not able to install correctly the project and run the test cases. I did as follow:
glide update
go test ./..
and got the following error message:
--- FAIL: TestOntId_RegIDWithPublicKey (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x8ff719]
goroutine 5 [running]:
testing.tRunner.func1(0xc0000e0300)
/usr/local/go/src/testing/testing.go:830 +0x388
panic(0x98b2a0, 0xf06250)
/usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/ontio/ontology-go-sdk.(*Wallet).NewIdentity(0x0, 0x10212, 0xece31c, 0x6, 0x6, 0xc0000b0d10, 0x4ecefd, 0xc05df0)
/home/dau/workspace/go/src/github.com/ontio/ontology-go-sdk/wallet.go:450 +0x29
github.com/ontio/ontology-go-sdk.(*Wallet).NewDefaultSettingIdentity(...)
/home/dau/workspace/go/src/github.com/ontio/ontology-go-sdk/wallet.go:472
github.com/ontio/ontology-go-sdk.TestOntId_RegIDWithPublicKey(0xc0000e0300)
/home/dau/workspace/go/src/github.com/ontio/ontology-go-sdk/native_contract_test.go:12 +0x70
testing.tRunner(0xc0000e0300, 0xa5f0d0)
/usr/local/go/src/testing/testing.go:865 +0xc0
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:916 +0x357
FAIL github.com/ontio/ontology-go-sdk 0.008s
? github.com/ontio/ontology-go-sdk/bip44 [no test files]
? github.com/ontio/ontology-go-sdk/client [no test files]
? github.com/ontio/ontology-go-sdk/common [no test files]
--- FAIL: TestOep4 (0.85s)
oep4_test.go:59: open ../../wallet.json: no such file or directory
FAIL
FAIL github.com/ontio/ontology-go-sdk/oep4 0.855s
? github.com/ontio/ontology-go-sdk/test [no test files]
? github.com/ontio/ontology-go-sdk/utils [no test files]
How to build iOS SDK with ontology-go-sdk?
when use ontology-go-sdk package
rpc.go:37:2: cannot find package "github.com/ontio/ontology/smartcontract/service/wasm" in any of:
/usr/lib/golang/src/github.com/ontio/ontology/smartcontract/service/wasm (from $GOROOT)
/root/gocode/src/github.com/ontio/ontology/smartcontract/service/wasm (from $GOPATH)
../utils/utils.go:28:2: cannot find package "github.com/ontio/ontology/vm/types" in any of:
/usr/lib/golang/src/github.com/ontio/ontology/vm/types (from $GOROOT)
/root/gocode/src/github.com/ontio/ontology/vm/types (from $GOPATH)
this api rpc function name is 'balanceOf', but the sdk is 'totalSupply'.
When use ontology-go-sdk, errors below are reported, we need to delete vendor/github.com/ontio/ontology/vendor/github.com/ontio/ontology-crypto to build successfully.
vendor/github.com/ontio/ontology-go-sdk/common/common.go:71:10: cannot use []"company/project/repo/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey literal (type []"company/project/repo/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey) as type []"company/project/repo/vendor/github.com/ontio/ontology/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey in field value
vendor/github.com/ontio/ontology-go-sdk/common/common.go:97:46: cannot use pubKeys (type []"company/project/repo/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey) as type []"company/project/repo/vendor/github.com/ontio/ontology/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey in argument to types.AddressFromMultiPubKeys
vendor/github.com/ontio/ontology-go-sdk/common/common.go:113:23: cannot use sigs.PubKeys (type []"company/project/repo/vendor/github.com/ontio/ontology/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey) as type []"company/project/repo/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey in argument to pubKeysEqual
vendor/github.com/ontio/ontology-go-sdk/common/common.go:125:11: cannot use pubKeys (type []"company/project/repo/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey) as type []"company/project/repo/vendor/github.com/ontio/ontology/vendor/github.com/ontio/ontology-crypto/keypair".PublicKey in field value
vendor/github.com/ontio/ontology-go-sdk/common/common.go:171:27: cannot use signer.SigScheme (type "company/project/repo/vendor/github.com/ontio/ontology/vendor/github.com/ontio/ontology-crypto/signature".SignatureScheme) as type "company/project/repo/vendor/github.com/ontio/ontology-crypto/signature".SignatureScheme in argument to "company/project/repo/vendor/github.com/ontio/ontology-crypto/signature".Sign
released version higher than v1.12 require package github.com/tendermint/[email protected], 1.14.0 require pakage github.com/tendermint/tendermint v0.33.5,
pakage [email protected] is too old ,iavl version now is up to 1.17.x, and require tendermint up to v0.35.2 , expect upgrade dependence iavl cause other projects can not downgrade tendermint version to v0.33.5
This is my test code
package main
import (
"fmt"
sdk "github.com/ontio/ontology-go-sdk"
)
func main() {
sdkClient := sdk.NewOntologySdk()
sdkClient.NewRpcClient().SetAddress("http://dappnode1.ont.io:20336")
height, err := sdkClient.GetCurrentBlockHeight()
if err != nil {
fmt.Printf("get current block height failed, err: %s\n", err.Error())
return
}
fmt.Printf("current block height is %d\n", height)
}
It returns some error info where I try to build the project.
# ontSdk
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: ignoring file /Users/lilin/go/pkg/mod/github.com/ontio/[email protected]/smartcontract/service/wasmvm/libwasmjit_onto_interface_darwin.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_wasmjit_bytes_destroy", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_bytes_destroy in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_bytes_destroy)
"_wasmjit_chain_context_create", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_chain_context_create in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_chain_context_create)
"_wasmjit_construct_result", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_construct_result in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_construct_result)
"_wasmjit_get_exec_step", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_get_exec_step in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_get_exec_step)
"_wasmjit_get_gas", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_get_gas in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_get_gas)
"_wasmjit_invoke", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_invoke in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_invoke)
"_wasmjit_service_index", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_service_index in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_service_index)
"_wasmjit_set_calloutput", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_set_calloutput in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_set_calloutput)
"_wasmjit_set_exec_step", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_set_exec_step in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_set_exec_step)
"_wasmjit_set_gas", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_set_gas in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_set_gas)
"_wasmjit_validate", referenced from:
__cgo_d02b16eeae27_Cfunc_wasmjit_validate in 000019.o
(maybe you meant: __cgo_d02b16eeae27_Cfunc_wasmjit_validate)
ld: symbol(s) not found for architecture arm64
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.