diff --git a/manager/eris-mint/evm/snative.go b/manager/eris-mint/evm/snative.go index 73275c7b5aa4a36e17d267b74409d214c1237a9e..92adbf300c5b339dfb33fdcc5903ffac2587e137 100644 --- a/manager/eris-mint/evm/snative.go +++ b/manager/eris-mint/evm/snative.go @@ -247,11 +247,12 @@ func (contract *SNativeContractDescription) Dispatch(appState AppState, return function.F(appState, caller, remainingArgs, gas) } -// We define the address of an SNative contact as the first 20 bytes of the sha3 +// We define the address of an SNative contact as the last 20 bytes of the sha3 // hash of its name func (contract *SNativeContractDescription) Address() abi.Address { var address abi.Address - copy(address[:], sha3.Sha3([]byte(contract.Name))[:abi.AddressLength]) + hash := sha3.Sha3([]byte(contract.Name)) + copy(address[:], hash[len(hash)-abi.AddressLength:]) return address } diff --git a/manager/eris-mint/evm/snative_test.go b/manager/eris-mint/evm/snative_test.go index a0722251afcabb91728fac73fe5a6ddfa9d27892..da0572b4535b42f6be66607ba29b1ce2e5fa8121 100644 --- a/manager/eris-mint/evm/snative_test.go +++ b/manager/eris-mint/evm/snative_test.go @@ -97,7 +97,7 @@ func TestSNativeContractDescription_Dispatch(t *testing.T) { func TestSNativeContractDescription_Address(t *testing.T) { contract := NewSNativeContract("A comment", "CoolButVeryLongNamedContractOfDoom") - assert.Equal(t, sha3.Sha3(([]byte)(contract.Name))[:20], contract.AddressBytes()) + assert.Equal(t, sha3.Sha3(([]byte)(contract.Name))[12:], contract.AddressBytes()) } //